Skip to content

Commit 91a4b42

Browse files
committed
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.
1 parent 483d40c commit 91a4b42

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

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 (url: {url})"))]
61+
UnsupportedChartSource { url: 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+
url: 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
},

0 commit comments

Comments
 (0)