[edge] Options: credentials directory override, so tests can run several edges in one process
This commit is contained in:
@@ -54,6 +54,8 @@ pub struct Options {
|
|||||||
pub share_revocations: Option<PathBuf>,
|
pub share_revocations: Option<PathBuf>,
|
||||||
/// Extra trust root for the ACME directory's TLS (Pebble in tests).
|
/// Extra trust root for the ACME directory's TLS (Pebble in tests).
|
||||||
pub acme_root: Option<PathBuf>,
|
pub acme_root: Option<PathBuf>,
|
||||||
|
/// Overrides `$CREDENTIALS_DIRECTORY` (tests running several edges in one process).
|
||||||
|
pub credentials_dir: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
@@ -71,13 +73,15 @@ pub fn default_trial_path(config: &Path) -> PathBuf {
|
|||||||
config.with_file_name(name)
|
config.with_file_name(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn credentials_dir() -> Option<PathBuf> {
|
fn credentials_dir(opts: &Options) -> Option<PathBuf> {
|
||||||
std::env::var_os("CREDENTIALS_DIRECTORY").map(PathBuf::from)
|
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.
|
/// Read the config, load secrets from `$CREDENTIALS_DIRECTORY`, load certificates.
|
||||||
pub fn prepare(opts: &Options) -> Result<Arc<Shared>, EdgeError> {
|
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())?;
|
let rt = runtime::build_file(&opts.config, creds.as_deref())?;
|
||||||
Ok(shared_for(rt, opts))
|
Ok(shared_for(rt, opts))
|
||||||
}
|
}
|
||||||
@@ -91,7 +95,7 @@ pub fn shared_for(rt: Runtime, opts: &Options) -> Arc<Shared> {
|
|||||||
trial: opts.trial_path(),
|
trial: opts.trial_path(),
|
||||||
revocations: opts.share_revocations.clone(),
|
revocations: opts.share_revocations.clone(),
|
||||||
},
|
},
|
||||||
credentials_dir(),
|
credentials_dir(opts),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user