Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions rust/stackable-cockpit/src/helm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,40 @@ pub struct ChartRepo {
pub url: String,
}

/// The kind of source a chart repo URL refers to.
///
/// [Self::Oci] and [Self::Local] don't need special handling, but [Self::Repo]
/// needs to call `helm::add_repo`.
///
/// Note: We don't yet support local repositories, so an error should be emitted
/// if the source is [Self::Local].
#[derive(Debug, PartialEq)]
pub enum ChartSourceKind {
/// OCI registry (url starts with `oci://`)
Oci,

/// Traditional index.yaml-based repository (url starts with `http://` or `https://`)
Repo,

/// Local filesystem path (not yet supported)
///
/// This is the fallback if not oci or http(s).
Local,
}

impl ChartRepo {
/// Determine the kind of chart source based on the URL scheme.
pub fn source_kind(&self) -> ChartSourceKind {
if self.url.starts_with("oci://") {
ChartSourceKind::Oci
} else if self.url.starts_with("http://") || self.url.starts_with("https://") {
ChartSourceKind::Repo
} else {
ChartSourceKind::Local
}
}
}

#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("failed to parse URL"))]
Expand Down Expand Up @@ -505,3 +539,27 @@ where

serde_yaml::from_str(&index_file_content).context(DeserializeYamlSnafu)
}

#[cfg(test)]
mod tests {
Comment thread
Techassi marked this conversation as resolved.
use rstest::rstest;

use super::*;

#[rstest]
#[case("oci://oci.stackable.tech/sdp-charts", ChartSourceKind::Oci)]
#[case(
"https://repo.stackable.tech/repository/helm-stable",
ChartSourceKind::Repo
)]
#[case("http://example.com/charts", ChartSourceKind::Repo)]
#[case("./charts/my-chart", ChartSourceKind::Local)]
#[case("/absolute/path/to/chart", ChartSourceKind::Local)]
fn source_kind(#[case] url: &str, #[case] expected: ChartSourceKind) {
let repo = ChartRepo {
name: "test".to_owned(),
url: url.to_owned(),
};
assert_eq!(repo.source_kind(), expected);
}
}
29 changes: 22 additions & 7 deletions rust/stackable-cockpit/src/platform/manifests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ pub enum Error {
source: helm::Error,
},

/// This error indicates that the Helm chart source kind is not supported.
#[snafu(display("local Helm chart sources are not yet supported (source: {chart_source:?})"))]
UnsupportedChartSource { chart_source: String },

/// This error indicates that Helm chart options could not be serialized
/// into YAML.
#[snafu(display("failed to serialize Helm chart options"))]
Expand Down Expand Up @@ -104,12 +108,23 @@ pub trait InstallManifestsExt {

info!(helm_chart.name, helm_chart.version, "Installing Helm chart",);

// Assumption: that all manifest helm charts refer to repos not registries
helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context(
AddHelmRepositorySnafu {
repo_name: helm_chart.repo.name.clone(),
},
)?;
let chart_source = match helm_chart.repo.source_kind() {
helm::ChartSourceKind::Repo => {
helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context(
AddHelmRepositorySnafu {
repo_name: helm_chart.repo.name.clone(),
},
)?;
&helm_chart.repo.name
}
helm::ChartSourceKind::Oci => &helm_chart.repo.url,
helm::ChartSourceKind::Local => {
return UnsupportedChartSourceSnafu {
chart_source: helm_chart.repo.url.clone(),
}
.fail();
}
};

// Serialize chart options to string
let values_yaml = serde_yaml::to_string(&helm_chart.options)
Expand All @@ -119,7 +134,7 @@ pub trait InstallManifestsExt {
helm::upgrade_or_install_release_from_repo_or_registry(
&helm_chart.release_name,
helm::ChartVersion {
chart_source: &helm_chart.repo.name,
chart_source,
chart_name: &helm_chart.name,
chart_version: Some(&helm_chart.version),
},
Expand Down
2 changes: 2 additions & 0 deletions rust/stackablectl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ All notable changes to this project will be documented in this file.
- Add `uninstall` subcommand for `demo`/`stack` commands ([#429]).
- Add confirmation prompt to `install` subcommand for namespace selection ([#429]).
- Add `--assume-yes` option for running commands non-interactively ([#429]).
- Support Helm charts sourced from OCI registries in demo/stack manifests ([#440]).

[#429]: https://github.com/stackabletech/stackable-cockpit/pull/429
[#438]: https://github.com/stackabletech/stackable-cockpit/pull/438
[#440]: https://github.com/stackabletech/stackable-cockpit/pull/440

## [1.4.0] - 2026-03-18

Expand Down
Loading