From e7c960f3fd84f00aac3b742c6759083d30232625 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Mon, 14 Oct 2024 11:56:12 -0700 Subject: [PATCH] reduce environment variable provider precedence - inverts precedence of variables providers giving the environment variable provider least precedence Signed-off-by: Kate Goldenring --- crates/variables/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/variables/src/lib.rs b/crates/variables/src/lib.rs index f5857e0d07..79130aeafa 100644 --- a/crates/variables/src/lib.rs +++ b/crates/variables/src/lib.rs @@ -19,20 +19,22 @@ use spin_factor_variables::runtime_config::RuntimeConfig; /// Resolves a runtime configuration for the variables factor from a TOML table. pub fn runtime_config_from_toml(table: &impl GetTomlValue) -> anyhow::Result { // Always include the environment variable provider. - let mut providers = vec![Box::::default() as _]; + let var_provider = vec![Box::::default() as _]; let value = table .get("variables_provider") .or_else(|| table.get("config_provider")); let Some(array) = value else { - return Ok(RuntimeConfig { providers }); + return Ok(RuntimeConfig { + providers: var_provider, + }); }; let provider_configs: Vec = array.clone().try_into()?; - let new_providers = provider_configs + let mut providers = provider_configs .into_iter() .map(VariableProviderConfiguration::into_provider) .collect::>>()?; - providers.extend(new_providers); + providers.extend(var_provider); Ok(RuntimeConfig { providers }) }