Skip to content

Commit 483d40c

Browse files
committed
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)://
1 parent 9d3b6b0 commit 483d40c

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

rust/stackable-cockpit/src/helm.rs

Lines changed: 34 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"))]

0 commit comments

Comments
 (0)