Class: Kube::Helm::Endpoint
- Inherits:
-
Object
- Object
- Kube::Helm::Endpoint
- Defined in:
- lib/kube/helm/endpoint.rb
Overview
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"
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#chart_ref(chart_name, repo_name: nil) ⇒ String
Build the chart reference string Helm expects.
-
#initialize(url) ⇒ Endpoint
constructor
A new instance of Endpoint.
-
#oci? ⇒ Boolean
Is this an OCI registry endpoint?.
-
#requires_add? ⇒ Boolean
Traditional Helm repos require ‘helm repo add`; OCI registries do not.
- #to_s ⇒ Object
Constructor Details
#initialize(url) ⇒ Endpoint
Returns a new instance of Endpoint.
28 29 30 31 32 33 |
# File 'lib/kube/helm/endpoint.rb', line 28 def initialize(url) raise ArgumentError, "url must be a String" unless url.is_a?(String) raise ArgumentError, "url must not be empty" if url.strip.empty? @url = url.chomp("/") end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
26 27 28 |
# File 'lib/kube/helm/endpoint.rb', line 26 def url @url end |
Instance Method Details
#==(other) ⇒ Object
70 71 72 |
# File 'lib/kube/helm/endpoint.rb', line 70 def ==(other) other.is_a?(Endpoint) && other.url == @url end |
#chart_ref(chart_name, repo_name: nil) ⇒ String
Build the chart reference string Helm expects.
For OCI: “oci://host/path/chart-name” For traditional: “repo-name/chart-name”
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/kube/helm/endpoint.rb', line 53 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 |
#oci? ⇒ Boolean
Is this an OCI registry endpoint?
36 37 38 |
# File 'lib/kube/helm/endpoint.rb', line 36 def oci? @url.start_with?("oci://") end |
#requires_add? ⇒ Boolean
Traditional Helm repos require ‘helm repo add`; OCI registries do not.
41 42 43 |
# File 'lib/kube/helm/endpoint.rb', line 41 def requires_add? !oci? end |
#to_s ⇒ Object
66 67 68 |
# File 'lib/kube/helm/endpoint.rb', line 66 def to_s @url end |