class Endpoint
Abstracts the differences between Helm chart sources.
Example: Traditional repo: needs `helm repo add` first
endpoint = Kube::Helm::Endpoint.new("https://charts.bitnami.com/bitnami")
endpoint.oci? #=> false
endpoint.requires_add? #=> true
endpoint.chart_ref("nginx", repo_name: "bitnami")
#=> "bitnami/nginx"
Example: OCI registry: no `repo add` step
endpoint = Kube::Helm::Endpoint.new("oci://ghcr.io/my-org/charts")
endpoint.oci? #=> true
endpoint.requires_add? #=> false
endpoint.chart_ref("nginx")
#=> "oci://ghcr.io/my-org/charts/nginx"
Signature
Definitions
def oci?
Is this an OCI registry endpoint?
Signature
-
returns
Boolean true if the URL uses the oci:// scheme.
Implementation
def oci?
@url.start_with?("oci://")
end
def requires_add?
Traditional repos require helm repo add; OCI ones do not.
Signature
-
returns
Boolean true unless this is an OCI endpoint.
Implementation
def requires_add?
!oci?
end
def chart_ref(chart_name, repo_name: nil)
Build the chart reference string Helm expects.
Example.
chart_ref("nginx") # OCI: "oci://host/path/nginx"
chart_ref("nginx", repo_name: "bitnami") # traditional: "bitnami/nginx"
Signature
-
parameter
chart_nameString the chart name, e.g. "nginx".
-
parameter
repo_nameString, nil the local repo alias, required for non-OCI.
-
returns
String the chart reference string Helm expects.
Implementation
def chart_ref(chart_name, repo_name: nil)
if oci?
"#{@url}/#{chart_name}"
else
if repo_name.nil?
raise ArgumentError,
"repo_name is required for non-OCI endpoints"
end
"#{repo_name}/#{chart_name}"
end
end