Skip to content

Commit 0a4c05a

Browse files
Factor out variable azure/vault providers into separate crates (#3215)
Signed-off-by: Brian Hardock <[email protected]>
1 parent daed2e3 commit 0a4c05a

File tree

12 files changed

+110
-27
lines changed

12 files changed

+110
-27
lines changed

Cargo.lock

Lines changed: 37 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/runtime-config/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ rust-version.workspace = true
1010

1111
[dependencies]
1212
anyhow = { workspace = true }
13+
serde = { workspace = true, features = ["derive"] }
1314
spin-common = { path = "../common" }
15+
spin-expressions = { path = "../expressions" }
1416
spin-factor-key-value = { path = "../factor-key-value" }
1517
spin-factor-llm = { path = "../factor-llm" }
1618
spin-factor-outbound-http = { path = "../factor-outbound-http" }
@@ -29,7 +31,10 @@ spin-key-value-redis = { path = "../key-value-redis" }
2931
spin-key-value-spin = { path = "../key-value-spin" }
3032
spin-sqlite = { path = "../sqlite" }
3133
spin-trigger = { path = "../trigger" }
32-
spin-variables = { path = "../variables" }
34+
spin-variables-azure = { path = "../variables-azure" }
35+
spin-variables-env = { path = "../variables-env" }
36+
spin-variables-static = { path = "../variables-static" }
37+
spin-variables-vault = { path = "../variables-vault" }
3338
toml = { workspace = true }
3439

3540
[dev-dependencies]

crates/runtime-config/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use spin_sqlite as sqlite;
2424
use spin_trigger::cli::UserProvidedPath;
2525
use toml::Value;
2626

27+
pub mod variables;
28+
2729
/// The default state directory for the trigger.
2830
pub const DEFAULT_STATE_DIR: &str = ".spin";
2931

@@ -342,9 +344,7 @@ impl FactorRuntimeConfigSource<VariablesFactor> for TomlRuntimeConfigSource<'_,
342344
fn get_runtime_config(
343345
&mut self,
344346
) -> anyhow::Result<Option<<VariablesFactor as spin_factors::Factor>::RuntimeConfig>> {
345-
Ok(Some(spin_variables::runtime_config_from_toml(
346-
&self.toml.table,
347-
)?))
347+
Ok(Some(variables::runtime_config_from_toml(&self.toml.table)?))
348348
}
349349
}
350350

crates/variables/src/lib.rs renamed to crates/runtime-config/src/variables.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
//! The runtime configuration for the variables factor used in the Spin CLI.
2-
3-
mod azure_key_vault;
4-
mod env;
5-
mod statik;
6-
mod vault;
7-
8-
pub use azure_key_vault::*;
9-
pub use env::*;
10-
pub use statik::*;
11-
pub use vault::*;
12-
131
use serde::Deserialize;
142
use spin_expressions::Provider;
15-
use spin_factors::{anyhow, runtime_config::toml::GetTomlValue};
16-
173
use spin_factor_variables::runtime_config::RuntimeConfig;
4+
use spin_factors::runtime_config::toml::GetTomlValue;
5+
use spin_variables_azure::{AzureKeyVaultProvider, AzureKeyVaultVariablesConfig};
6+
use spin_variables_env::{EnvVariablesConfig, EnvVariablesProvider};
7+
use spin_variables_static::StaticVariablesProvider;
8+
use spin_variables_vault::VaultVariablesProvider;
189

1910
/// Resolves a runtime configuration for the variables factor from a TOML table.
2011
pub fn runtime_config_from_toml(table: &impl GetTomlValue) -> anyhow::Result<RuntimeConfig> {
@@ -57,7 +48,7 @@ impl VariableProviderConfiguration {
5748
pub fn into_provider(self) -> anyhow::Result<Box<dyn Provider>> {
5849
let provider: Box<dyn Provider> = match self {
5950
VariableProviderConfiguration::Static(provider) => Box::new(provider),
60-
VariableProviderConfiguration::Env(config) => Box::new(env::EnvVariablesProvider::new(
51+
VariableProviderConfiguration::Env(config) => Box::new(EnvVariablesProvider::new(
6152
config.prefix,
6253
|s| std::env::var(s),
6354
config.dotenv_path,
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "spin-variables"
2+
name = "spin-variables-azure"
33
version.workspace = true
44
authors.workspace = true
55
edition.workspace = true
@@ -12,15 +12,11 @@ rust-version.workspace = true
1212
azure_core = { git = "https://github.com/azure/azure-sdk-for-rust", rev = "8c4caa251c3903d5eae848b41bb1d02a4d65231c" }
1313
azure_identity = { git = "https://github.com/azure/azure-sdk-for-rust", rev = "8c4caa251c3903d5eae848b41bb1d02a4d65231c" }
1414
azure_security_keyvault = { git = "https://github.com/azure/azure-sdk-for-rust", rev = "8c4caa251c3903d5eae848b41bb1d02a4d65231c" }
15-
dotenvy = "0.15"
1615
serde = { workspace = true }
1716
spin-expressions = { path = "../expressions" }
18-
spin-factor-variables = { path = "../factor-variables" }
1917
spin-factors = { path = "../factors" }
2018
spin-world = { path = "../world" }
21-
tokio = { workspace = true, features = ["rt-multi-thread"] }
2219
tracing = { workspace = true }
23-
vaultrs = "0.7"
2420

2521
[lints]
2622
workspace = true

crates/variables-env/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "spin-variables-env"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
rust-version.workspace = true
10+
11+
[dependencies]
12+
dotenvy = "0.15"
13+
serde = { workspace = true }
14+
spin-expressions = { path = "../expressions" }
15+
spin-factors = { path = "../factors" }
16+
spin-world = { path = "../world" }
17+
tokio = { workspace = true, features = ["rt-multi-thread"] }
18+
tracing = { workspace = true }
19+
20+
[lints]
21+
workspace = true
File renamed without changes.

crates/variables-static/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "spin-variables-static"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
rust-version.workspace = true
10+
11+
[dependencies]
12+
serde = { workspace = true }
13+
spin-expressions = { path = "../expressions" }
14+
spin-factors = { path = "../factors" }
15+
16+
[lints]
17+
workspace = true
File renamed without changes.

0 commit comments

Comments
 (0)