From 4ecf766baf5f517ce1eae9403a7c4783d9925a32 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 17 Mar 2026 16:19:42 +0100 Subject: [PATCH 1/4] feat: Add `STACK` and `DEMO` templating parameters Co-authored-by: Xenia Fischer --- README.md | 8 ++++++++ rust/stackable-cockpit/src/platform/demo/params.rs | 6 ++++++ rust/stackable-cockpit/src/platform/demo/spec.rs | 6 ++++-- rust/stackable-cockpit/src/platform/manifests.rs | 10 ++++++++-- rust/stackable-cockpit/src/platform/stack/params.rs | 4 ++++ rust/stackable-cockpit/src/platform/stack/spec.rs | 2 ++ rust/stackablectl/CHANGELOG.md | 6 ++++++ rust/stackablectl/src/cmds/demo.rs | 2 ++ rust/stackablectl/src/cmds/stack.rs | 5 +++-- 9 files changed, 43 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 688e4083..c003321a 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,11 @@ hooks are: [pre-commit]: https://pre-commit.com/ [web-readme]: ./web/README.md [lib-readme]: ./rust/stackable-cockpit/README.md + +### Templating variables + +| Variable | Availability | Content | +| ----------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | +| `NAMESPACE` | Always | The namespace where the stack and demo (not the operators!) are deployed into | +| `STACK` | Always (both in stack and demo manifests) | The name of the stack | +| `DEMO` | In demos manifests: Always
In stack manifests: Only when deployed as part of a demo! | The name of the demo | diff --git a/rust/stackable-cockpit/src/platform/demo/params.rs b/rust/stackable-cockpit/src/platform/demo/params.rs index 84f54d2b..d116c71b 100644 --- a/rust/stackable-cockpit/src/platform/demo/params.rs +++ b/rust/stackable-cockpit/src/platform/demo/params.rs @@ -4,6 +4,12 @@ use stackable_operator::kvp::Labels; use crate::platform::operator::ChartSourceType; pub struct DemoInstallParameters { + /// Name of the demo, which is always present + pub demo_name: String, + + /// Name of the stack, which is always present, as a demo builds on top of a stack + pub stack_name: String, + pub operator_namespace: String, pub demo_namespace: String, diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 96107d49..17f5294c 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -153,13 +153,13 @@ impl DemoSpec { .await?; let stack_install_parameters = StackInstallParameters { + stack_name: self.stack.clone(), + demo_name: Some(install_parameters.demo_name.clone()), operator_namespace: install_parameters.operator_namespace.clone(), stack_namespace: install_parameters.demo_namespace.clone(), parameters: install_parameters.stack_parameters.clone(), labels: install_parameters.stack_labels.clone(), skip_release: install_parameters.skip_release, - stack_name: self.stack.clone(), - demo_name: None, chart_source: install_parameters.chart_source.clone(), operator_values: install_parameters.operator_values.clone(), }; @@ -204,6 +204,8 @@ impl DemoSpec { &self.manifests, ¶ms, &install_params.demo_namespace, + &install_params.demo_name, + Some(&install_params.stack_name), install_params.labels, client, transfer_client, diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 15fcf306..267b5d89 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -70,6 +70,8 @@ pub trait InstallManifestsExt { manifests: &[ManifestSpec], parameters: &HashMap, namespace: &str, + stack_name: &str, + demo_name: Option<&str>, labels: Labels, client: &Client, transfer_client: &xfer::Client, @@ -80,9 +82,13 @@ pub trait InstallManifestsExt { Span::current().pb_set_length(manifests.len() as u64); let mut parameters = parameters.clone(); - // We add the NAMESPACE parameter, so that stacks/demos can use that to render e.g. the - // fqdn service names [which contain the namespace]. + // We need some additional templating capabilities, e.g. the namespace, so that stacks/demos + // can use that to render e.g. the fqdn service names [which contain the namespace]. parameters.insert("NAMESPACE".to_owned(), namespace.to_owned()); + parameters.insert("STACK".to_owned(), stack_name.into()); + if let Some(demo_name) = demo_name { + parameters.insert("DEMO".to_owned(), demo_name.into()); + } for manifest in manifests { let parameters = parameters.clone(); diff --git a/rust/stackable-cockpit/src/platform/stack/params.rs b/rust/stackable-cockpit/src/platform/stack/params.rs index 0688eba2..d9d044e3 100644 --- a/rust/stackable-cockpit/src/platform/stack/params.rs +++ b/rust/stackable-cockpit/src/platform/stack/params.rs @@ -5,7 +5,11 @@ use crate::platform::operator::ChartSourceType; #[derive(Debug)] pub struct StackInstallParameters { + /// Optional name of the demo, which is only present in case this stack is installed as part of + /// a demo. This is unset in case a stack is installed directly. pub demo_name: Option, + + /// Name of the stack, which is always present pub stack_name: String, pub operator_namespace: String, diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index 2bb39d62..58ace389 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -249,6 +249,8 @@ impl StackSpec { &self.manifests, ¶meters, &install_params.stack_namespace, + &install_params.stack_name, + install_params.demo_name.as_deref(), install_params.labels, client, transfer_client, diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index a1e2ad53..6aa7caa0 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Add `STACK` and `DEMO` templating parameters. Have a look at the README for details ([#XXX]). + +[#XXX]: https://github.com/stackabletech/stackable-cockpit/pull/XXX + ## [1.3.0] - 2026-03-16 ### Added diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index 251a94fe..57cebffe 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -388,6 +388,8 @@ async fn install_cmd( .context(LoadOperatorValuesSnafu)?; let install_parameters = DemoInstallParameters { + demo_name: args.demo_name.clone(), + stack_name: demo.stack.clone(), operator_namespace: args.namespaces.operator_namespace.clone(), demo_namespace: args.namespaces.namespace.clone(), stack_parameters: args.stack_parameters.clone(), diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index f4045f9a..490d74e0 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -359,12 +359,13 @@ async fn install_cmd( .context(LoadOperatorValuesSnafu)?; let install_parameters = StackInstallParameters { + stack_name: args.stack_name.clone(), + // There is no demo when installing only a stack + demo_name: None, operator_namespace: args.namespaces.operator_namespace.clone(), stack_namespace: args.namespaces.namespace.clone(), - stack_name: args.stack_name.clone(), parameters: args.parameters.clone(), skip_release: args.skip_release, - demo_name: None, labels, chart_source: ChartSourceType::from(cli.chart_type()), operator_values, From 993a651511f8b6b3f4ca041a2d0490fead12077b Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 17 Mar 2026 16:26:29 +0100 Subject: [PATCH 2/4] changelog --- rust/stackablectl/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index 6aa7caa0..2ff5a338 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -6,9 +6,9 @@ All notable changes to this project will be documented in this file. ### Added -- Add `STACK` and `DEMO` templating parameters. Have a look at the README for details ([#XXX]). +- Add `STACK` and `DEMO` templating parameters. Have a look at the README for details ([#432]). -[#XXX]: https://github.com/stackabletech/stackable-cockpit/pull/XXX +[#432]: https://github.com/stackabletech/stackable-cockpit/pull/432 ## [1.3.0] - 2026-03-16 From 9fdf9ccef5ea6b161cee646cf340fb41b37bf330 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 18 Mar 2026 08:23:54 +0100 Subject: [PATCH 3/4] clippy --- rust/stackable-cockpit/src/platform/manifests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 267b5d89..56181dde 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -65,7 +65,7 @@ pub enum Error { pub trait InstallManifestsExt { // TODO (Techassi): This step shouldn't care about templating the manifests nor fetching them from remote #[instrument(skip_all, fields(%namespace, indicatif.pb_show = true))] - #[allow(async_fn_in_trait)] + #[allow(clippy::too_many_arguments, async_fn_in_trait)] async fn install_manifests( manifests: &[ManifestSpec], parameters: &HashMap, From 07ad43954a473598ea43be7e6d332911f5ec58c0 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 18 Mar 2026 08:45:07 +0100 Subject: [PATCH 4/4] Consitently list stack before demo --- rust/stackable-cockpit/src/platform/demo/params.rs | 6 +++--- rust/stackable-cockpit/src/platform/demo/spec.rs | 4 ++-- rust/stackable-cockpit/src/platform/stack/params.rs | 6 +++--- rust/stackablectl/src/cmds/demo.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rust/stackable-cockpit/src/platform/demo/params.rs b/rust/stackable-cockpit/src/platform/demo/params.rs index d116c71b..3f1486ac 100644 --- a/rust/stackable-cockpit/src/platform/demo/params.rs +++ b/rust/stackable-cockpit/src/platform/demo/params.rs @@ -4,12 +4,12 @@ use stackable_operator::kvp::Labels; use crate::platform::operator::ChartSourceType; pub struct DemoInstallParameters { - /// Name of the demo, which is always present - pub demo_name: String, - /// Name of the stack, which is always present, as a demo builds on top of a stack pub stack_name: String, + /// Name of the demo, which is always present + pub demo_name: String, + pub operator_namespace: String, pub demo_namespace: String, diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 17f5294c..bce047dc 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -204,8 +204,8 @@ impl DemoSpec { &self.manifests, ¶ms, &install_params.demo_namespace, - &install_params.demo_name, - Some(&install_params.stack_name), + &install_params.stack_name, + Some(&install_params.demo_name), install_params.labels, client, transfer_client, diff --git a/rust/stackable-cockpit/src/platform/stack/params.rs b/rust/stackable-cockpit/src/platform/stack/params.rs index d9d044e3..b3cf9717 100644 --- a/rust/stackable-cockpit/src/platform/stack/params.rs +++ b/rust/stackable-cockpit/src/platform/stack/params.rs @@ -5,13 +5,13 @@ use crate::platform::operator::ChartSourceType; #[derive(Debug)] pub struct StackInstallParameters { + /// Name of the stack, which is always present + pub stack_name: String, + /// Optional name of the demo, which is only present in case this stack is installed as part of /// a demo. This is unset in case a stack is installed directly. pub demo_name: Option, - /// Name of the stack, which is always present - pub stack_name: String, - pub operator_namespace: String, pub stack_namespace: String, diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index 57cebffe..4980ff30 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -388,8 +388,8 @@ async fn install_cmd( .context(LoadOperatorValuesSnafu)?; let install_parameters = DemoInstallParameters { - demo_name: args.demo_name.clone(), stack_name: demo.stack.clone(), + demo_name: args.demo_name.clone(), operator_namespace: args.namespaces.operator_namespace.clone(), demo_namespace: args.namespaces.namespace.clone(), stack_parameters: args.stack_parameters.clone(),