summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/config.rs b/src/config.rs
index f8fe51a..e4a7e6d 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -2,44 +2,27 @@ use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
-/// Fallback tag for a provisioning backend when the caller has no image of its own.
pub const DEFAULT_SANDBOX_IMAGE: &str = "aur-build-sandbox:latest";
-/// Where build code runs (§8, the sandbox seam).
-///
-/// An enum with required fields rather than a string plus a `validate()`: the
-/// string version silently fell through to loopback.
#[derive(Clone, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)]
pub enum Sandbox {
- /// Subprocesses of this process; isolation is *none* (§14's sudo rules are
- /// the boundary). The default, and the only kind needing no configuration.
Loopback,
- /// Sandboxes that dial in over the agent protocol (§8a); the hub never
- /// provisions them.
Remote {
- /// Agent dial-in listener; port 0 resolves at bind.
listen: String,
/// Rendezvous secret. Deploy it like a credential.
token: String,
- /// Asserts hub and sandbox see the same filesystem — required, because
- /// the workspace is not shipped to a remote sandbox (§8a). See
- /// `Config`'s startup guard.
#[serde(default)]
shared_workspace: bool,
},
- /// Disposable Kata VMs provisioned by a Kubernetes CRD, so the orchestrator
- /// enforces the TTL even if the hub dies (§8a).
AgentSandbox {
api: String,
namespace: String,
/// Never logged.
bearer: String,
- /// The `sandbox-agent` entrypoint.
image: String,
listen: String,
token: String,
- /// As [`Sandbox::Remote`].
#[serde(default)]
shared_workspace: bool,
},
@@ -103,7 +86,6 @@ impl Sandbox {
}
}
- /// `None` for kinds that provision nothing.
pub fn image(&self) -> Option<&str> {
match self {
Sandbox::AgentSandbox { image, .. } => Some(image),
@@ -122,63 +104,43 @@ impl Sandbox {
pub const KINDS: [&'static str; 3] = ["loopback", "remote", "agent-sandbox"];
}
-/// Runtime configuration. Persisted as `<root>/config.json`.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct Config {
- /// Holds db, mirrors, caches, store, repo and logs.
pub root: PathBuf,
pub repo_name: String,
pub arch: String,
- /// Signs packages *and* the database (decision 22).
pub signing_key_id: String,
- /// Loopback only by default (§14).
pub bind: String,
- /// One credential, no user table.
pub password: String,
pub base_url: String,
pub build_profile: String,
pub git_bin: String,
pub makepkg_bin: String,
- /// The lease set is installed with `pacman -U` inside the sandbox (§8).
pub pacman_bin: String,
pub repo_add_bin: String,
pub gpg_bin: String,
- /// Unprivileged user running PKGBUILD code (§14). Empty = current user.
pub build_user: String,
pub sandbox: Sandbox,
- /// Absent unless built with `test-support` (§16a).
#[cfg(feature = "test-support")]
#[serde(default, skip_serializing_if = "TestHooks::is_empty")]
pub hooks: TestHooks,
- /// Default 1, so the chroot pool needs only one warm root.
pub max_concurrent_builds: usize,
pub lease_secs: i64,
pub min_free_disk_mb: u64,
- /// Transient step failures only (§8.4).
pub max_transient_attempts: i64,
pub dispatch_tick_secs: u64,
}
-/// The test harness's handles on a real pipeline (§16a).
-///
-/// Each exists because a *fake* pipeline would test something else: I4 needs a
-/// process that really dies between the tmp write and the rename, I5 needs a step
-/// that really dies mid-child, I9 needs a PKGBUILD that really reaches outside its
-/// staging dir.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct TestHooks {
pub path_prepend: Option<PathBuf>,
pub shim_manifest: Option<PathBuf>,
pub shim_dir: Option<PathBuf>,
- /// `before-rename` or `after-rename`, for I4.
pub publish_fault: Option<String>,
- /// The named shim must fail, e.g. `makepkg`.
pub shim_fail: Option<String>,
- /// The named shim SIGKILLs the pipeline process mid-step (I5).
pub shim_kill_parent: Option<String>,
- /// The build shim plants a symlink to this path in its srcdir (I9).
pub shim_plant_link: Option<String>,
}
@@ -231,10 +193,6 @@ impl Config {
.to_string()
}
- /// Refuse a configuration that cannot work, before anything builds with it.
- ///
- /// The enum makes the impossible unrepresentable; this catches what a type cannot
- /// see — empty-but-present fields, and the assertion the type leaves defaulted.
pub fn validate(&self) -> crate::error::Result<()> {
let require = |field: &str, value: &str| -> crate::error::Result<()> {
if value.trim().is_empty() {
@@ -267,7 +225,6 @@ impl Config {
if self.sandbox.shared_workspace() {
return Ok(());
}
- // A remote build only works where hub and sandbox see the same path.
Err(crate::error::Error::invalid(format!(
concat!(
"sandbox kind \"{}\" was not told that hub and sandbox share a filesystem: ",
@@ -281,12 +238,6 @@ impl Config {
)))
}
- /// Read `<root>/config.json`.
- ///
- /// **The root is the directory the config file was found in.** The `root` field
- /// inside the file is documentation, not a second source of truth; honouring a
- /// relative field by re-joining it onto the config's directory is what turned
- /// `--root runtime` into `runtime/runtime/…`.
pub fn load(root: &Path) -> crate::error::Result<Self> {
let dir = absolute(root)?;
let p = dir.join("config.json");
@@ -307,8 +258,6 @@ impl Config {
pub fn save(&self) -> crate::error::Result<()> {
std::fs::create_dir_all(&self.root)?;
let mut out = self.clone();
- // Absolutize on the way out, so a config written from a relative
- // `--root` can never be misread.
out.root = absolute(&self.root)?;
std::fs::write(
self.root.join("config.json"),
@@ -317,8 +266,6 @@ impl Config {
Ok(())
}
- /// Child environment as pairs — the form the remote backend puts on the
- /// wire, so a remote child sees what a local one would.
#[cfg_attr(not(feature = "test-support"), allow(unused_variables))]
pub fn child_env_pairs(&self) -> Vec<(String, String)> {
#[cfg_attr(not(feature = "test-support"), allow(unused_mut))]
@@ -355,7 +302,6 @@ impl Config {
}
}
- /// Create the directory tree the server needs. Idempotent.
pub fn ensure_dirs(&self) -> crate::error::Result<()> {
for d in [
self.root.clone(),
@@ -427,9 +373,6 @@ impl Config {
}
}
-/// A retired key holding exactly what `init` used to write for a local
-/// deployment states nothing the default does not already state, so it is noise
-/// from an old file rather than lost intent. Anything else is refused.
fn retired_key_is_inert(key: &str, value: &str) -> bool {
match key {
"sandbox_backend" => value == "loopback",
@@ -438,10 +381,6 @@ fn retired_key_is_inert(key: &str, value: &str) -> bool {
}
}
-/// The sandbox configuration moved from four flat keys to one tagged object
-/// ([`Sandbox`]). A retired key is refused only when it would have changed
-/// behaviour: `init` used to write `sandbox_backend: "loopback"` alongside three
-/// empty strings, and a config carrying exactly that keeps loading untouched.
fn check_retired_sandbox_keys(v: &serde_json::Value) -> crate::error::Result<()> {
const RETIRED: [&str; 4] = ["sandbox_backend", "agent_listen", "agent_token", "sandbox_image"];
let named: Vec<String> = RETIRED
@@ -471,9 +410,6 @@ fn check_retired_sandbox_keys(v: &serde_json::Value) -> crate::error::Result<()>
)))
}
-/// Absolutize without resolving symlinks and without requiring the path to
-/// exist, both of which `canonicalize` insists on — and `init` saves its config
-/// before the tree under it is complete.
fn absolute(p: &Path) -> crate::error::Result<PathBuf> {
Ok(std::path::absolute(p)?)
}