Skip to content

Commit c6d532f

Browse files
committed
feat: Support OCI registries
1 parent 15cd9ea commit c6d532f

File tree

13 files changed

+53
-15
lines changed

13 files changed

+53
-15
lines changed

rust/stackable-cockpit/src/constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub const HELM_REPO_NAME_TEST: &str = "stackable-test";
2222
pub const HELM_REPO_NAME_DEV: &str = "stackable-dev";
2323
pub const HELM_REPO_INDEX_FILE: &str = "index.yaml";
2424

25+
pub const HELM_OCI_REGISTRY: &str = "oci://oci.stackable.tech/sdp-charts";
26+
2527
pub const HELM_DEFAULT_CHART_VERSION: &str = ">0.0.0-0";
2628

2729
pub const PRODUCT_NAMES: &[&str] = &[

rust/stackable-cockpit/src/helm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,20 @@ impl Display for UninstallReleaseStatus {
182182
}
183183

184184
pub struct ChartVersion<'a> {
185-
pub repo_name: &'a str,
185+
pub chart_source: &'a str,
186186
pub chart_name: &'a str,
187187
pub chart_version: Option<&'a str>,
188188
}
189189

190-
/// Installs a Helm release from a repo.
190+
/// Installs a Helm release from a repo or registry.
191191
///
192192
/// This function expects the fully qualified Helm release name. In case of our
193193
/// operators this is: `<PRODUCT_NAME>-operator`.
194194
#[instrument]
195-
pub fn install_release_from_repo(
195+
pub fn install_release_from_repo_or_registry(
196196
release_name: &str,
197197
ChartVersion {
198-
repo_name,
198+
chart_source,
199199
chart_name,
200200
chart_version,
201201
}: ChartVersion,
@@ -244,7 +244,7 @@ pub fn install_release_from_repo(
244244
}
245245
}
246246

247-
let full_chart_name = format!("{repo_name}/{chart_name}");
247+
let full_chart_name = format!("{chart_source}/{chart_name}");
248248
let chart_version = chart_version.unwrap_or(HELM_DEFAULT_CHART_VERSION);
249249

250250
debug!(

rust/stackable-cockpit/src/platform/demo/params.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ pub struct DemoInstallParameters {
1010

1111
pub stack_labels: Labels,
1212
pub labels: Labels,
13+
pub use_registry: bool,
1314
}

rust/stackable-cockpit/src/platform/demo/spec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ impl DemoSpec {
159159
skip_release: install_parameters.skip_release,
160160
stack_name: self.stack.clone(),
161161
demo_name: None,
162+
use_registry: install_parameters.use_registry,
162163
};
163164

164165
stack

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub enum Error {
6262

6363
pub trait InstallManifestsExt {
6464
// TODO (Techassi): This step shouldn't care about templating the manifests nor fetching them from remote
65+
// TODO aken: do we support helm charts from registries?
6566
#[instrument(skip_all)]
6667
#[allow(async_fn_in_trait)]
6768
async fn install_manifests(
@@ -94,6 +95,7 @@ pub trait InstallManifestsExt {
9495
helm_chart.name, helm_chart.version
9596
);
9697

98+
// TODO aken: assuming all manifest helm charts refer to repos not registries
9799
helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context(
98100
AddHelmRepositorySnafu {
99101
repo_name: helm_chart.repo.name.clone(),
@@ -105,10 +107,10 @@ pub trait InstallManifestsExt {
105107
.context(SerializeOptionsSnafu)?;
106108

107109
// Install the Helm chart using the Helm wrapper
108-
helm::install_release_from_repo(
110+
helm::install_release_from_repo_or_registry(
109111
&helm_chart.release_name,
110112
helm::ChartVersion {
111-
repo_name: &helm_chart.repo.name,
113+
chart_source: &helm_chart.repo.name,
112114
chart_name: &helm_chart.name,
113115
chart_version: Some(&helm_chart.version),
114116
},

rust/stackable-cockpit/src/platform/operator/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use snafu::{ensure, ResultExt, Snafu};
55
use tracing::{info, instrument};
66

77
use crate::{
8-
constants::{HELM_REPO_NAME_DEV, HELM_REPO_NAME_STABLE, HELM_REPO_NAME_TEST},
8+
constants::{
9+
HELM_OCI_REGISTRY, HELM_REPO_NAME_DEV, HELM_REPO_NAME_STABLE, HELM_REPO_NAME_TEST,
10+
},
911
helm,
1012
utils::operator_chart_name,
1113
};
@@ -176,20 +178,25 @@ impl OperatorSpec {
176178

177179
/// Installs the operator using Helm.
178180
#[instrument(skip_all)]
179-
pub fn install(&self, namespace: &str) -> Result<(), helm::Error> {
181+
pub fn install(&self, namespace: &str, use_registry: bool) -> Result<(), helm::Error> {
180182
info!("Installing operator {}", self);
181183

182184
let version = self.version.as_ref().map(|v| v.to_string());
183-
let helm_repo = self.helm_repo_name();
184185
let helm_name = self.helm_name();
185186

187+
let chart_source = if use_registry {
188+
HELM_OCI_REGISTRY.to_string()
189+
} else {
190+
self.helm_repo_name()
191+
};
192+
186193
// Install using Helm
187-
helm::install_release_from_repo(
194+
helm::install_release_from_repo_or_registry(
188195
&helm_name,
189196
helm::ChartVersion {
190197
chart_version: version.as_deref(),
191198
chart_name: &helm_name,
192-
repo_name: &helm_repo,
199+
chart_source: &chart_source,
193200
},
194201
None,
195202
namespace,

rust/stackable-cockpit/src/platform/release/spec.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl ReleaseSpec {
5656
include_products: &[String],
5757
exclude_products: &[String],
5858
namespace: &str,
59+
use_registry: bool,
5960
) -> Result<()> {
6061
info!("Installing release");
6162

@@ -73,7 +74,9 @@ impl ReleaseSpec {
7374
.context(OperatorSpecParseSnafu)?;
7475

7576
// Install operator
76-
operator.install(&namespace).context(HelmInstallSnafu)?;
77+
operator
78+
.install(&namespace, use_registry)
79+
.context(HelmInstallSnafu)?;
7780

7881
info!("Installed {product_name}-operator");
7982

rust/stackable-cockpit/src/platform/stack/params.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ pub struct StackInstallParameters {
1111
pub parameters: Vec<String>,
1212
pub skip_release: bool,
1313
pub labels: Labels,
14+
pub use_registry: bool,
1415
}

rust/stackable-cockpit/src/platform/stack/spec.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl StackSpec {
173173
release_list,
174174
&install_parameters.operator_namespace,
175175
&install_parameters.product_namespace,
176+
install_parameters.use_registry,
176177
)
177178
.await?;
178179
}
@@ -195,6 +196,7 @@ impl StackSpec {
195196
release_list: release::ReleaseList,
196197
operator_namespace: &str,
197198
product_namespace: &str,
199+
use_registry: bool,
198200
) -> Result<(), Error> {
199201
info!("Trying to install release {}", self.release);
200202

@@ -207,7 +209,7 @@ impl StackSpec {
207209

208210
// Install the release
209211
release
210-
.install(&self.operators, &[], operator_namespace)
212+
.install(&self.operators, &[], operator_namespace, use_registry)
211213
.await
212214
.context(InstallReleaseSnafu)
213215
}

rust/stackablectl/src/cmds/demo.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ to specify operator versions."
107107

108108
#[command(flatten)]
109109
namespaces: CommonNamespaceArgs,
110+
111+
/// TODO
112+
#[arg(long, long_help = "TODO")]
113+
use_registry: bool,
110114
}
111115

112116
#[derive(Debug, Args)]
@@ -329,6 +333,7 @@ async fn install_cmd(
329333
skip_release: args.skip_release,
330334
stack_labels,
331335
labels,
336+
use_registry: args.use_registry,
332337
};
333338

334339
demo.install(

0 commit comments

Comments
 (0)