From 2be41fc9468ddfdf700a721c88043e8051b57581 Mon Sep 17 00:00:00 2001 From: Aminu Oluwaseun Joshua Date: Tue, 16 Sep 2025 16:44:43 +0100 Subject: [PATCH] Adds allow_unset field for variables Signed-off-by: Aminu Oluwaseun Joshua --- crates/loader/src/local.rs | 4 ++-- crates/manifest/src/schema/common.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/loader/src/local.rs b/crates/loader/src/local.rs index abcd9015e..c214ab3e6 100644 --- a/crates/loader/src/local.rs +++ b/crates/loader/src/local.rs @@ -607,8 +607,8 @@ fn locked_metadata( fn locked_variable(variable: v2::Variable) -> Result { ensure!( - variable.required ^ variable.default.is_some(), - "must be `required` OR have a `default`" + variable.required ^ variable.default.is_some() ^ variable.allow_unset, + "must be `required` OR have a `default` OR set to `allow_unset`" ); Ok(locked::Variable { description: variable.description, diff --git a/crates/manifest/src/schema/common.rs b/crates/manifest/src/schema/common.rs index 0c6127a2d..09925b852 100644 --- a/crates/manifest/src/schema/common.rs +++ b/crates/manifest/src/schema/common.rs @@ -41,6 +41,13 @@ pub struct Variable { /// Learn more: https://spinframework.dev/variables#adding-variables-to-your-applications #[serde(default, skip_serializing_if = "is_false")] pub secret: bool, + /// If set, the variable may be unset. + /// + /// Example: `allow_unset = true` + /// + /// Learn more: https://spinframework.dev/variables#adding-variables-to-your-applications + #[serde(default, skip_serializing_if = "is_false")] + pub allow_unset: bool, } /// The file, package, or URL containing the component Wasm binary. This may be: