Class: Eien::Secrets::UpdateTask
- Defined in:
- lib/eien/secrets/update_task.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#key_pairs ⇒ Object
readonly
Returns the value of attribute key_pairs.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Task
#context, #namespace, #task_config
Instance Method Summary collapse
-
#initialize(context, app, name, **key_pairs) ⇒ UpdateTask
constructor
A new instance of UpdateTask.
- #run! ⇒ Object
Methods included from Helpers::TimeHelpers
Constructor Details
#initialize(context, app, name, **key_pairs) ⇒ UpdateTask
Returns a new instance of UpdateTask.
8 9 10 11 12 13 |
# File 'lib/eien/secrets/update_task.rb', line 8 def initialize(context, app, name, **key_pairs) @app = app @name = name @key_pairs = key_pairs super(context) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/eien/secrets/update_task.rb', line 6 def app @app end |
#key_pairs ⇒ Object (readonly)
Returns the value of attribute key_pairs.
6 7 8 |
# File 'lib/eien/secrets/update_task.rb', line 6 def key_pairs @key_pairs end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/eien/secrets/update_task.rb', line 6 def name @name end |
Instance Method Details
#run! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eien/secrets/update_task.rb', line 15 def run! the_app = Eien.app_from_name(context, app) client = kubeclient_builder.build_v1_kubeclient(context) app_name = the_app..name secret_name = ::Eien.secret_name(name) target_namespace = the_app.spec.namespace secret = begin client.get_secret(secret_name, target_namespace) rescue Kubeclient::ResourceNotFoundError new_secret = Kubeclient::Resource.new( apiVersion: "v1", kind: "Secret", metadata: { name: secret_name, namespace: target_namespace, labels: { "#{::Eien::LABEL_PREFIX}/app": app_name, }, }, type: "Opaque", data: { }, ) client.create_secret(new_secret) end secret.data = prepare_key_pairs(secret) client.update_secret(secret) end |