diff --git a/akd/Cargo.lock b/akd/Cargo.lock index 4ee8bb0663..4003cac612 100644 --- a/akd/Cargo.lock +++ b/akd/Cargo.lock @@ -113,6 +113,7 @@ dependencies = [ "akd_storage", "anyhow", "async-trait", + "bitwarden-akd-configuration", "clap", "hex", "owo-colors", @@ -120,6 +121,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "uuid", ] [[package]] diff --git a/akd/crates/akd_test_utility/Cargo.toml b/akd/crates/akd_test_utility/Cargo.toml index c692fb5e05..d1d6eeebdb 100644 --- a/akd/crates/akd_test_utility/Cargo.toml +++ b/akd/crates/akd_test_utility/Cargo.toml @@ -12,7 +12,7 @@ path = "src/main.rs" [dependencies] akd = { workspace = true } -akd_storage = { workspace = true} +akd_storage = { workspace = true } anyhow = "1" async-trait = { workspace = true } clap = { version = "4", features = ["derive"] } @@ -21,7 +21,13 @@ owo-colors = "4" rand = "0.8" tokio.workspace = true tracing.workspace = true -tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "ansi"] } +tracing-subscriber = { workspace = true, features = [ + "env-filter", + "fmt", + "ansi", +] } +bitwarden-akd-configuration = { workspace = true } +uuid = { workspace = true } [lints] workspace = true diff --git a/akd/crates/akd_test_utility/src/main.rs b/akd/crates/akd_test_utility/src/main.rs index 140a781810..0cdfa68e53 100644 --- a/akd/crates/akd_test_utility/src/main.rs +++ b/akd/crates/akd_test_utility/src/main.rs @@ -18,7 +18,8 @@ use tracing_subscriber::Layer; mod commands; mod directory_host; -type TC = akd::ExperimentalConfiguration; +// type TC = akd::ExperimentalConfiguration; +type TC = bitwarden_akd_configuration::BitwardenV1Configuration; #[derive(ValueEnum, Clone, Debug)] enum LogLevel { @@ -73,6 +74,10 @@ struct CliArgs { #[clap(long = "connection-string", short = 'c')] connection_string: Option, + /// Installation context UUID (also reads from AKD_INSTALLATION_CONTEXT env var) + #[clap(long = "installation-context", short = 'i')] + installation_context: Option, + /// Log level #[clap( value_enum, @@ -115,9 +120,22 @@ async fn main() -> Result<()> { .or_else(|| std::env::var("AKD_MSSQL_CONNECTION_STRING").ok()) .context("Connection string required via --connection-string or AKD_MSSQL_CONNECTION_STRING env var")?; + // Get installation context from CLI or env var + let installation_context_str = args + .installation_context + .clone() + .or_else(|| std::env::var("AKD_INSTALLATION_CONTEXT").ok()) + .context("Installation context UUID required via --installation-context or AKD_INSTALLATION_CONTEXT env var")?; + + // Parse installation context as UUID + let installation_context = uuid::Uuid::parse_str(&installation_context_str) + .context("Installation context must be a valid UUID")?; + // Initialize logging let mut layers = Vec::new(); + bitwarden_akd_configuration::BitwardenV1Configuration::init(installation_context); + // If a log file is specified, only log to file // Otherwise, log to console if let Some(ref log_file) = args.log_file {