debian-mirror-gitlab/lib/gitlab/kubernetes/kubeconfig/entry/cluster.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
827 B
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
module Gitlab
module Kubernetes
module Kubeconfig
module Entry
class Cluster
attr_reader :name
def initialize(name:, url:, ca_pem: nil)
@name = name
@url = url
@ca_pem = ca_pem
end
def to_h
{
name: name,
cluster: cluster
}
end
private
attr_reader :url, :ca_pem
def cluster
{
server: url,
'certificate-authority-data': certificate_authority_data
}.compact
end
def certificate_authority_data
return unless ca_pem.present?
Base64.strict_encode64(ca_pem)
end
end
end
end
end
end