Class: Eien::Secrets::ExportTask

Inherits:
Task
  • Object
show all
Defined in:
lib/eien/secrets/export_task.rb

Instance Attribute Summary collapse

Attributes inherited from Task

#context, #namespace, #task_config

Instance Method Summary collapse

Methods included from Helpers::TimeHelpers

#summarize_age

Constructor Details

#initialize(context, app, name) ⇒ ExportTask

Returns a new instance of ExportTask.



8
9
10
11
12
# File 'lib/eien/secrets/export_task.rb', line 8

def initialize(context, app, name)
  @app = app
  @name = name
  super(context)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



6
7
8
# File 'lib/eien/secrets/export_task.rb', line 6

def app
  @app
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/eien/secrets/export_task.rb', line 6

def name
  @name
end

Instance Method Details

#run!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/eien/secrets/export_task.rb', line 14

def run!
  the_app = Eien.app_from_name(context, app)
  client = kubeclient_builder.build_v1_kubeclient(context)

  secret = begin
    client.get_secret(::Eien.secret_name(name), the_app.spec.namespace)
  rescue Kubeclient::ResourceNotFoundError
    nil
  end

  return if secret.nil?

  key_pairs = secret.data.to_h || {}
  key_pairs.map do |key, value|
    puts "#{key}=#{Base64.strict_decode64(value)}"
  end
end