mirror of
https://github.com/vhaudiquet/ecrou.git
synced 2026-11-12 22:22:44 +00:00
refactor(config): remove the unwired config module
Config::load was never called: the DNS-override story it carried contradicts the actual resolver flow, and nothing in the CLI or snap advertised a key. Delete the module and every mention of the ecrou.yaml file in SPEC and the snap; the XDG_CONFIG_HOME redirect in the command chain served only that file.
This commit is contained in:
1 parent
12148ac951
commit
006fce632b
4 files changed
+6
-54
No files matched your search
@@ -343,8 +343,6 @@ tool.
|
|||||||
└── <...>.provisioned # hot-cell marker
|
└── <...>.provisioned # hot-cell marker
|
||||||
```
|
```
|
||||||
|
|
||||||
`~/.config/ecrou.yaml` carries over (DNS overrides today).
|
|
||||||
|
|
||||||
## Snap packaging
|
## Snap packaging
|
||||||
|
|
||||||
Confinement: strict. Plugs: `network`, `home`, `kvm`. Manual
|
Confinement: strict. Plugs: `network`, `home`, `kvm`. Manual
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
use anyhow::Context;
|
|
||||||
|
|
||||||
use crate::Result;
|
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Default)]
|
|
||||||
pub struct Config {
|
|
||||||
#[serde(default)]
|
|
||||||
pub dns: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Config {
|
|
||||||
pub fn load() -> Result<Self> {
|
|
||||||
let config_path = dirs::config_dir().map(|p| p.join("ecrou.yaml"));
|
|
||||||
|
|
||||||
match config_path {
|
|
||||||
Some(path) if path.exists() => {
|
|
||||||
let content =
|
|
||||||
std::fs::read_to_string(&path).context("Failed to read config file")?;
|
|
||||||
|
|
||||||
let config: Config =
|
|
||||||
serde_yaml::from_str(&content).context("Failed to parse config file")?;
|
|
||||||
|
|
||||||
// Set defaults
|
|
||||||
let config = Config {
|
|
||||||
dns: if config.dns.is_empty() {
|
|
||||||
vec!["1.1.1.1".to_string()]
|
|
||||||
} else {
|
|
||||||
config.dns
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(config)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
// No config file, use defaults
|
|
||||||
Ok(Config {
|
|
||||||
dns: vec!["1.1.1.1".to_string()],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
//! embeds the library exactly the way the CLI does - a [`RootfsCache`]
|
//! embeds the library exactly the way the CLI does - a [`RootfsCache`]
|
||||||
//! to prepare a rootfs, then [`run`] to boot it.
|
//! to prepare a rootfs, then [`run`] to boot it.
|
||||||
|
|
||||||
pub mod config;
|
|
||||||
pub mod distro;
|
pub mod distro;
|
||||||
pub mod download;
|
pub mod download;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|||||||
+6
-8
@@ -27,7 +27,6 @@ description: |
|
|||||||
## Configuration and cache
|
## Configuration and cache
|
||||||
|
|
||||||
- image cache: `~/snap/ecrou/common/cache/ecrou`
|
- image cache: `~/snap/ecrou/common/cache/ecrou`
|
||||||
- config: `~/snap/ecrou/common/config/ecrou.yaml`
|
|
||||||
|
|
||||||
The home interface does not cover dotfiles, so the XDG
|
The home interface does not cover dotfiles, so the XDG
|
||||||
directories are redirected into the snap's common data area.
|
directories are redirected into the snap's common data area.
|
||||||
@@ -58,17 +57,16 @@ parts:
|
|||||||
build-packages: [cmake, perl]
|
build-packages: [cmake, perl]
|
||||||
override-build: |
|
override-build: |
|
||||||
craftctl default
|
craftctl default
|
||||||
# The home interface stops at dotfiles, so ~/.cache and
|
# The home interface stops at dotfiles, so ~/.cache is
|
||||||
# ~/.config are unreachable under strict confinement. Point the
|
# unreachable under strict confinement. Point the XDG cache
|
||||||
# XDG lookups (the dirs crate honors these variables) into the
|
# lookup (the dirs crate honors the variable) into the snap's
|
||||||
# snap's durable area, shared across refreshes.
|
# durable area, shared across refreshes.
|
||||||
mkdir -p "$CRAFT_PART_INSTALL/command-chain"
|
mkdir -p "$CRAFT_PART_INSTALL/command-chain"
|
||||||
cat > "$CRAFT_PART_INSTALL/command-chain/ecrou-env" <<'EOF'
|
cat > "$CRAFT_PART_INSTALL/command-chain/ecrou-env" <<'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
XDG_CACHE_HOME="$SNAP_USER_COMMON/cache"
|
XDG_CACHE_HOME="$SNAP_USER_COMMON/cache"
|
||||||
XDG_CONFIG_HOME="$SNAP_USER_COMMON/config"
|
export XDG_CACHE_HOME
|
||||||
export XDG_CACHE_HOME XDG_CONFIG_HOME
|
mkdir -p "$XDG_CACHE_HOME"
|
||||||
mkdir -p "$XDG_CACHE_HOME" "$XDG_CONFIG_HOME"
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
EOF
|
EOF
|
||||||
chmod 755 "$CRAFT_PART_INSTALL/command-chain/ecrou-env"
|
chmod 755 "$CRAFT_PART_INSTALL/command-chain/ecrou-env"
|
||||||
|
|||||||
Reference in new issue
Block a user