File tree Expand file tree Collapse file tree
rust/stackable-cockpit/src Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ]
4276pub enum Error {
4377 #[ snafu( display( "failed to parse URL" ) ) ]
You can’t perform that action at this time.
0 commit comments