[edge] Options: credentials directory override, so tests can run several edges in one process

This commit is contained in:
2026-11-07 18:16:14 +01:00
parent 6ce1fe9d2b
commit 74d1bc02da
+8 -4
View File
@@ -54,6 +54,8 @@ pub struct Options {
pub share_revocations: Option<PathBuf>,
/// Extra trust root for the ACME directory's TLS (Pebble in tests).
pub acme_root: Option<PathBuf>,
/// Overrides `$CREDENTIALS_DIRECTORY` (tests running several edges in one process).
pub credentials_dir: Option<PathBuf>,
}
impl Options {
@@ -71,13 +73,15 @@ pub fn default_trial_path(config: &Path) -> PathBuf {
config.with_file_name(name)
}
fn credentials_dir() -> Option<PathBuf> {
std::env::var_os("CREDENTIALS_DIRECTORY").map(PathBuf::from)
fn credentials_dir(opts: &Options) -> Option<PathBuf> {
opts.credentials_dir
.clone()
.or_else(|| std::env::var_os("CREDENTIALS_DIRECTORY").map(PathBuf::from))
}
/// Read the config, load secrets from `$CREDENTIALS_DIRECTORY`, load certificates.
pub fn prepare(opts: &Options) -> Result<Arc<Shared>, EdgeError> {
let creds = credentials_dir();
let creds = credentials_dir(opts);
let rt = runtime::build_file(&opts.config, creds.as_deref())?;
Ok(shared_for(rt, opts))
}
@@ -91,7 +95,7 @@ pub fn shared_for(rt: Runtime, opts: &Options) -> Arc<Shared> {
trial: opts.trial_path(),
revocations: opts.share_revocations.clone(),
},
credentials_dir(),
credentials_dir(opts),
)
}