Class: Kubecontrol::Resources::Secret

Inherits:
Object
  • Object
show all
Defined in:
lib/kubecontrol/resources/secret.rb

Constant Summary collapse

RESOURCE_NAME =
'secrets'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, data, age, namespace, client) ⇒ Secret

Returns a new instance of Secret.



11
12
13
14
15
16
17
18
# File 'lib/kubecontrol/resources/secret.rb', line 11

def initialize(name, type, data, age, namespace, client)
  @name = name
  @type = type
  @data = data
  @age = age
  @namespace = namespace
  @client = client
end

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age.



9
10
11
# File 'lib/kubecontrol/resources/secret.rb', line 9

def age
  @age
end

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/kubecontrol/resources/secret.rb', line 9

def client
  @client
end

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/kubecontrol/resources/secret.rb', line 9

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/kubecontrol/resources/secret.rb', line 9

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



9
10
11
# File 'lib/kubecontrol/resources/secret.rb', line 9

def namespace
  @namespace
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/kubecontrol/resources/secret.rb', line 9

def type
  @type
end

Instance Method Details

#data_valuesObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kubecontrol/resources/secret.rb', line 20

def data_values
  @data_values ||= begin
                     std_out, _std_err, exit_code = @client.kubectl_command("get secret #{@name} -o json")
                     if exit_code.zero?
                       json_secret = JSON.parse(std_out)
                       json_secret['data'].reduce({}) {|h, (k,v)|  h[k] = Base64.decode64(v); h }
                     else
                       {}
                     end
                   end
end