Skip to content

Commit 3ab83b6

Browse files
authored
feat: stacks and demo supports OCI helmCharts (#440)
* chore: Add ChartSourceKind for oci/repo/local Note: Local isn't yet supported, but it is a fallback for when the URL doesn't match oci:// or http(s):// * feat: Add support for OCI repositories Note: Only non-OCI remote charts need the helm::add_repo() call. We emit an error if a Local (non oci:// or http(s)://) value is given. * test: Ensure ChartRepo::source_kind gives expected variants This seems trivial now in this set of changes, but is intended to catch future regressions * chore: Update changelog * chore: cargo update -p rustls-webpki * chore: Rename path to chart_source, and use the Debug impl * test: Use rstest Also use str::to_owned()
1 parent 9d3b6b0 commit 3ab83b6

5 files changed

Lines changed: 86 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/stackable-cockpit/src/helm.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,40 @@ pub struct ChartRepo {
3838
pub url: String,
3939
}
4040

41+
/// The kind of source a chart repo URL refers to.
42+
///
43+
/// [Self::Oci] and [Self::Local] don't need special handling, but [Self::Repo]
44+
/// needs to call `helm::add_repo`.
45+
///
46+
/// Note: We don't yet support local repositories, so an error should be emitted
47+
/// if the source is [Self::Local].
48+
#[derive(Debug, PartialEq)]
49+
pub enum ChartSourceKind {
50+
/// OCI registry (url starts with `oci://`)
51+
Oci,
52+
53+
/// Traditional index.yaml-based repository (url starts with `http://` or `https://`)
54+
Repo,
55+
56+
/// Local filesystem path (not yet supported)
57+
///
58+
/// This is the fallback if not oci or http(s).
59+
Local,
60+
}
61+
62+
impl ChartRepo {
63+
/// Determine the kind of chart source based on the URL scheme.
64+
pub fn source_kind(&self) -> ChartSourceKind {
65+
if self.url.starts_with("oci://") {
66+
ChartSourceKind::Oci
67+
} else if self.url.starts_with("http://") || self.url.starts_with("https://") {
68+
ChartSourceKind::Repo
69+
} else {
70+
ChartSourceKind::Local
71+
}
72+
}
73+
}
74+
4175
#[derive(Debug, Snafu)]
4276
pub enum Error {
4377
#[snafu(display("failed to parse URL"))]
@@ -505,3 +539,27 @@ where
505539

506540
serde_yaml::from_str(&index_file_content).context(DeserializeYamlSnafu)
507541
}
542+
543+
#[cfg(test)]
544+
mod tests {
545+
use rstest::rstest;
546+
547+
use super::*;
548+
549+
#[rstest]
550+
#[case("oci://oci.stackable.tech/sdp-charts", ChartSourceKind::Oci)]
551+
#[case(
552+
"https://repo.stackable.tech/repository/helm-stable",
553+
ChartSourceKind::Repo
554+
)]
555+
#[case("http://example.com/charts", ChartSourceKind::Repo)]
556+
#[case("./charts/my-chart", ChartSourceKind::Local)]
557+
#[case("/absolute/path/to/chart", ChartSourceKind::Local)]
558+
fn source_kind(#[case] url: &str, #[case] expected: ChartSourceKind) {
559+
let repo = ChartRepo {
560+
name: "test".to_owned(),
561+
url: url.to_owned(),
562+
};
563+
assert_eq!(repo.source_kind(), expected);
564+
}
565+
}

rust/stackable-cockpit/src/platform/manifests.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ pub enum Error {
5656
source: helm::Error,
5757
},
5858

59+
/// This error indicates that the Helm chart source kind is not supported.
60+
#[snafu(display("local Helm chart sources are not yet supported (source: {chart_source:?})"))]
61+
UnsupportedChartSource { chart_source: String },
62+
5963
/// This error indicates that Helm chart options could not be serialized
6064
/// into YAML.
6165
#[snafu(display("failed to serialize Helm chart options"))]
@@ -104,12 +108,23 @@ pub trait InstallManifestsExt {
104108

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

107-
// Assumption: that all manifest helm charts refer to repos not registries
108-
helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context(
109-
AddHelmRepositorySnafu {
110-
repo_name: helm_chart.repo.name.clone(),
111-
},
112-
)?;
111+
let chart_source = match helm_chart.repo.source_kind() {
112+
helm::ChartSourceKind::Repo => {
113+
helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context(
114+
AddHelmRepositorySnafu {
115+
repo_name: helm_chart.repo.name.clone(),
116+
},
117+
)?;
118+
&helm_chart.repo.name
119+
}
120+
helm::ChartSourceKind::Oci => &helm_chart.repo.url,
121+
helm::ChartSourceKind::Local => {
122+
return UnsupportedChartSourceSnafu {
123+
chart_source: helm_chart.repo.url.clone(),
124+
}
125+
.fail();
126+
}
127+
};
113128

114129
// Serialize chart options to string
115130
let values_yaml = serde_yaml::to_string(&helm_chart.options)
@@ -119,7 +134,7 @@ pub trait InstallManifestsExt {
119134
helm::upgrade_or_install_release_from_repo_or_registry(
120135
&helm_chart.release_name,
121136
helm::ChartVersion {
122-
chart_source: &helm_chart.repo.name,
137+
chart_source,
123138
chart_name: &helm_chart.name,
124139
chart_version: Some(&helm_chart.version),
125140
},

rust/stackablectl/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ All notable changes to this project will be documented in this file.
1010
- Add `uninstall` subcommand for `demo`/`stack` commands ([#429]).
1111
- Add confirmation prompt to `install` subcommand for namespace selection ([#429]).
1212
- Add `--assume-yes` option for running commands non-interactively ([#429]).
13+
- Support Helm charts sourced from OCI registries in demo/stack manifests ([#440]).
1314

1415
[#429]: https://github.com/stackabletech/stackable-cockpit/pull/429
1516
[#438]: https://github.com/stackabletech/stackable-cockpit/pull/438
17+
[#440]: https://github.com/stackabletech/stackable-cockpit/pull/440
1618

1719
## [1.4.0] - 2026-03-18
1820

0 commit comments

Comments
 (0)