class Repo
Models a Helm chart repository (traditional or OCI).
Wraps the lifecycle commands (helm repo add, helm repo update,
helm repo remove) and fetches charts for rendering.
When a +cluster+ is provided, all Helm commands are scoped to that cluster's kubeconfig.
repo = Kube::Helm::Repo.new("bitnami", url: "https://charts.bitnami.com/bitnami")
chart = repo.fetch("nginx", version: "18.1.0")
manifest = chart.apply_values("replicaCount" => 3 )
One-liner
manifest = Kube::Helm::Repo
.new("bitnami", url: "https://charts.bitnami.com/bitnami")
.fetch("nginx", version: "18.1.0")
.apply_values("replicaCount" => 3 )
Definitions
def initialize(name, url:, cluster: nil)
Implementation
def initialize(name, url:, cluster: nil)
unless name.is_a?(String) && !name.strip.empty?
raise ArgumentError, "name must be a non-empty String"
end
@name = name
@endpoint = Endpoint.new(url)
@cluster = cluster
end
def add
Register this repo with the local Helm client. No-op for OCI registries.
Implementation
def add
tap do
if endpoint.requires_add?
name = @name
url = endpoint.url
helm.run(
helm.call { repo.add.(name).(url) }.to_s
)
end
end
end
def update
Update the local chart index for this repo. No-op for OCI registries.
Implementation
def update
tap do
if endpoint.requires_add?
name = @name
helm.run(
helm.call { repo.update.(name) }.to_s
)
end
end
end
def remove
Remove this repo from the local Helm client. No-op for OCI registries.
Implementation
def remove
tap do
if endpoint.requires_add?
name = @name
helm.run(
helm.call { repo.remove.(name) }.to_s
)
end
end
end
def fetch(chart_name, version: nil)
Fetch a chart from this repo.
Adds and updates the repo, retrieves the Chart.yaml metadata via
helm show chart, and returns a Chart object with the ref set
for subsequent helm commands.
Implementation
def fetch(chart_name, version: nil)
add
update
ref = endpoint.chart_ref(chart_name, repo_name: @name)
helm.run(
helm.call {
if version
show.chart.(ref).version(version)
else
show.chart.(ref)
end
}.to_s
).then do |yaml_output|
(YAML.safe_load(yaml_output, permitted_classes: [Symbol]) || {}).then do |data|
Chart.new(data, ref: ref, cluster: @cluster)
end
end
end
def oci?
Is this an OCI-backed repo?
Implementation
def oci?
endpoint.oci?
end