Class: K8y::Kubeconfig::Cluster

Inherits:
Object
  • Object
show all
Defined in:
lib/k8y/kubeconfig/cluster.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, insecure_skip_tls_verify:, certificate_authority:, certificate_authority_data:, server:) ⇒ Cluster

Returns a new instance of Cluster.



21
22
23
24
25
26
27
# File 'lib/k8y/kubeconfig/cluster.rb', line 21

def initialize(name:, insecure_skip_tls_verify:, certificate_authority:, certificate_authority_data:, server:)
  @name = name
  @insecure_skip_tls_verify = insecure_skip_tls_verify
  @certificate_authority = certificate_authority
  @certificate_authority_data = certificate_authority_data
  @server = server
end

Instance Attribute Details

#certificate_authorityObject (readonly)

Returns the value of attribute certificate_authority.



6
7
8
# File 'lib/k8y/kubeconfig/cluster.rb', line 6

def certificate_authority
  @certificate_authority
end

#certificate_authority_dataObject (readonly)

Returns the value of attribute certificate_authority_data.



6
7
8
# File 'lib/k8y/kubeconfig/cluster.rb', line 6

def certificate_authority_data
  @certificate_authority_data
end

#insecure_skip_tls_verifyObject (readonly)

Returns the value of attribute insecure_skip_tls_verify.



6
7
8
# File 'lib/k8y/kubeconfig/cluster.rb', line 6

def insecure_skip_tls_verify
  @insecure_skip_tls_verify
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/k8y/kubeconfig/cluster.rb', line 6

def name
  @name
end

#serverObject (readonly)

Returns the value of attribute server.



6
7
8
# File 'lib/k8y/kubeconfig/cluster.rb', line 6

def server
  @server
end

Class Method Details

.from_hash(hash) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/k8y/kubeconfig/cluster.rb', line 8

def self.from_hash(hash)
  cluster = hash.fetch("cluster")
  new(
    insecure_skip_tls_verify: cluster.fetch("insecure-skip-tls-verify", false),
    certificate_authority: cluster.fetch("certificate-authority", nil),
    certificate_authority_data: cluster.fetch("certificate-authority-data", nil),
    server: cluster.fetch("server"),
    name: hash.fetch("name")
  )
rescue Psych::Exception, KeyError => e
  raise Error, e
end