Skip to content

Commit 42e8ef4

Browse files
Merge pull request #1918 from fibonacci1729/variables
Rename config to variables
2 parents e2b4098 + 7c6d865 commit 42e8ef4

File tree

76 files changed

+808
-718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+808
-718
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ terminal = { path = "crates/terminal" }
4949
spin-app = { path = "crates/app" }
5050
spin-build = { path = "crates/build" }
5151
spin-common = { path = "crates/common" }
52-
spin-config = { path = "crates/config" }
5352
spin-doctor = { path = "crates/doctor" }
5453
spin-http = { path = "crates/http" }
55-
spin-trigger-http = { path = "crates/trigger-http" }
5654
spin-loader = { path = "crates/loader" }
5755
spin-locked-app = { path = "crates/locked-app" }
5856
spin-manifest = { path = "crates/manifest" }
@@ -61,6 +59,9 @@ spin-plugins = { path = "crates/plugins" }
6159
spin-redis-engine = { path = "crates/redis" }
6260
spin-templates = { path = "crates/templates" }
6361
spin-trigger = { path = "crates/trigger" }
62+
spin-trigger-http = { path = "crates/trigger-http" }
63+
spin-variables = { path = "crates/variables" }
64+
6465
tempfile = "3.8.0"
6566
tokio = { version = "1.23", features = ["full"] }
6667
toml = "0.6"

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use cargo_target_dep::build_target_dep;
99

1010
const RUST_HTTP_INTEGRATION_TEST: &str = "tests/http/simple-spin-rust";
1111
const RUST_HTTP_INTEGRATION_ENV_TEST: &str = "tests/http/headers-env-routes-test";
12-
const RUST_HTTP_VAULT_CONFIG_TEST: &str = "tests/http/vault-config-test";
12+
const RUST_HTTP_VAULT_VARIABLES_TEST: &str = "tests/http/vault-variables-test";
1313
const RUST_OUTBOUND_REDIS_INTEGRATION_TEST: &str = "tests/outbound-redis/http-rust-outbound-redis";
1414
const TIMER_TRIGGER_INTEGRATION_TEST: &str = "examples/spin-timer/app-example";
1515
const WASI_HTTP_INTEGRATION_TEST: &str = "examples/wasi-http-rust-streaming-outgoing-body";
@@ -88,7 +88,7 @@ error: the `wasm32-wasi` target is not installed
8888

8989
cargo_build(RUST_HTTP_INTEGRATION_TEST);
9090
cargo_build(RUST_HTTP_INTEGRATION_ENV_TEST);
91-
cargo_build(RUST_HTTP_VAULT_CONFIG_TEST);
91+
cargo_build(RUST_HTTP_VAULT_VARIABLES_TEST);
9292
cargo_build(RUST_OUTBOUND_REDIS_INTEGRATION_TEST);
9393
cargo_build(TIMER_TRIGGER_INTEGRATION_TEST);
9494
cargo_build(WASI_HTTP_INTEGRATION_TEST);

crates/redis/tests/rust/Cargo.lock

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

crates/trigger/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ sanitize-filename = "0.4"
3737
serde = "1.0.188"
3838
serde_json = "1.0"
3939
spin-app = { path = "../app" }
40-
spin-config = { path = "../config" }
4140
spin-core = { path = "../core" }
4241
spin-loader = { path = "../loader" }
4342
spin-manifest = { path = "../manifest" }
43+
spin-variables = { path = "../variables" }
4444
terminal = { path = "../terminal" }
4545
tokio = { version = "1.23", features = ["fs"] }
4646
toml = "0.5.9"

crates/trigger/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ impl<Executor: TriggerExecutor> TriggerExecutorBuilder<Executor> {
139139
)?;
140140
self.loader.add_dynamic_host_component(
141141
&mut builder,
142-
spin_config::ConfigHostComponent::new(runtime_config.config_providers()),
142+
spin_variables::VariablesHostComponent::new(
143+
runtime_config.variables_providers(),
144+
),
143145
)?;
144146
}
145147

crates/trigger/src/runtime_config.rs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pub mod config_provider;
21
pub mod key_value;
32
pub mod llm;
43
pub mod sqlite;
4+
pub mod variables_provider;
55

66
use std::{
77
collections::HashMap,
@@ -15,10 +15,10 @@ use serde::Deserialize;
1515
use spin_sqlite::Connection;
1616

1717
use self::{
18-
config_provider::{ConfigProvider, ConfigProviderOpts},
1918
key_value::{KeyValueStore, KeyValueStoreOpts},
2019
llm::LlmComputeOpts,
2120
sqlite::SqliteDatabaseOpts,
21+
variables_provider::{VariablesProvider, VariablesProviderOpts},
2222
};
2323

2424
pub const DEFAULT_STATE_DIR: &str = ".spin";
@@ -57,12 +57,12 @@ impl RuntimeConfig {
5757
Ok(())
5858
}
5959

60-
/// Return a Vec of configured [`spin_config::Provider`]s.
61-
pub fn config_providers(&self) -> Vec<ConfigProvider> {
62-
let default_provider = ConfigProviderOpts::default_provider_opts(self).build_provider();
63-
let mut providers: Vec<ConfigProvider> = vec![default_provider];
60+
/// Return a Vec of configured [`VariablesProvider`]s.
61+
pub fn variables_providers(&self) -> Vec<VariablesProvider> {
62+
let default_provider = VariablesProviderOpts::default_provider_opts(self).build_provider();
63+
let mut providers: Vec<VariablesProvider> = vec![default_provider];
6464
providers.extend(self.opts_layers().flat_map(|opts| {
65-
opts.config_providers
65+
opts.variables_providers
6666
.iter()
6767
.map(|opts| opts.build_provider())
6868
}));
@@ -198,8 +198,8 @@ pub struct RuntimeConfigOpts {
198198
#[serde(default)]
199199
pub llm_compute: Option<LlmComputeOpts>,
200200

201-
#[serde(rename = "config_provider", default)]
202-
pub config_providers: Vec<ConfigProviderOpts>,
201+
#[serde(rename = "variables_provider", alias = "config_provider", default)]
202+
pub variables_providers: Vec<VariablesProviderOpts>,
203203

204204
#[serde(rename = "key_value_store", default)]
205205
pub key_value_stores: HashMap<String, KeyValueStoreOpts>,
@@ -307,11 +307,11 @@ mod tests {
307307
}
308308

309309
#[test]
310-
fn config_providers_from_file() -> Result<()> {
310+
fn deprecated_config_provider_in_runtime_config_file() -> Result<()> {
311311
let mut config = RuntimeConfig::new(None);
312312

313313
// One default provider
314-
assert_eq!(config.config_providers().len(), 1);
314+
assert_eq!(config.variables_providers().len(), 1);
315315

316316
merge_config_toml(
317317
&mut config,
@@ -323,7 +323,29 @@ mod tests {
323323
mount = "root"
324324
},
325325
);
326-
assert_eq!(config.config_providers().len(), 2);
326+
assert_eq!(config.variables_providers().len(), 2);
327+
328+
Ok(())
329+
}
330+
331+
#[test]
332+
fn variables_providers_from_file() -> Result<()> {
333+
let mut config = RuntimeConfig::new(None);
334+
335+
// One default provider
336+
assert_eq!(config.variables_providers().len(), 1);
337+
338+
merge_config_toml(
339+
&mut config,
340+
toml! {
341+
[[variables_provider]]
342+
type = "vault"
343+
url = "http://vault"
344+
token = "secret"
345+
mount = "root"
346+
},
347+
);
348+
assert_eq!(config.variables_providers().len(), 2);
327349

328350
Ok(())
329351
}

0 commit comments

Comments
 (0)