class Endpoint
Abstracts the differences between Helm chart sources.
Traditional Helm repos require helm repo add before charts can be
referenced, and charts are addressed as "repo-name/chart-name".
OCI registries need no repo add step, and charts are addressed as
the full OCI URI: "oci://host/path/chart-name".
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"
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"
Definitions
def oci?
Is this an OCI registry endpoint?
Implementation
def oci?
@url.start_with?("oci://")
end
def requires_add?
Traditional Helm repos require helm repo add; OCI registries do not.
Implementation
def requires_add?
!oci?
end
def chart_ref(chart_name, repo_name: nil)
Build the chart reference string Helm expects.
For OCI: "oci://host/path/chart-name" For traditional: "repo-name/chart-name"
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