Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br>In stack manifests: Only when deployed as part of a demo! | The name of the demo |
6 changes: 6 additions & 0 deletions rust/stackable-cockpit/src/platform/demo/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
6 changes: 4 additions & 2 deletions rust/stackable-cockpit/src/platform/demo/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down Expand Up @@ -204,6 +204,8 @@ impl DemoSpec {
&self.manifests,
&params,
&install_params.demo_namespace,
&install_params.demo_name,
Some(&install_params.stack_name),
install_params.labels,
client,
transfer_client,
Expand Down
12 changes: 9 additions & 3 deletions rust/stackable-cockpit/src/platform/manifests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ 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))]
Comment thread
NickLarsenNZ marked this conversation as resolved.
#[allow(async_fn_in_trait)]
#[allow(clippy::too_many_arguments, async_fn_in_trait)]
async fn install_manifests(
manifests: &[ManifestSpec],
parameters: &HashMap<String, String>,
namespace: &str,
stack_name: &str,
demo_name: Option<&str>,
labels: Labels,
client: &Client,
transfer_client: &xfer::Client,
Expand All @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions rust/stackable-cockpit/src/platform/stack/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// Name of the stack, which is always present
pub stack_name: String,

pub operator_namespace: String,
Expand Down
2 changes: 2 additions & 0 deletions rust/stackable-cockpit/src/platform/stack/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ impl StackSpec {
&self.manifests,
&parameters,
&install_params.stack_namespace,
&install_params.stack_name,
install_params.demo_name.as_deref(),
install_params.labels,
client,
transfer_client,
Expand Down
6 changes: 6 additions & 0 deletions rust/stackablectl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([#432]).

[#432]: https://github.com/stackabletech/stackable-cockpit/pull/432

## [1.3.0] - 2026-03-16

### Added
Expand Down
2 changes: 2 additions & 0 deletions rust/stackablectl/src/cmds/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
5 changes: 3 additions & 2 deletions rust/stackablectl/src/cmds/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading