Class: Eien::Config::UpdateTask
- Defined in:
- lib/eien/config/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/config/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/config/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/config/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/config/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 |
# File 'lib/eien/config/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 config_map_name = ::Eien.config_map_name(name) target_namespace = the_app.spec.namespace config_map = begin client.get_config_map(config_map_name, target_namespace) rescue Kubeclient::ResourceNotFoundError new_config_map = Kubeclient::Resource.new( apiVersion: "v1", kind: "config_map", metadata: { name: config_map_name, namespace: target_namespace, labels: { "#{::Eien::LABEL_PREFIX}/app": app_name, }, }, data: { }, ) client.create_config_map(new_config_map) end config_map.data = prepare_key_pairs(config_map) client.update_config_map(config_map) end |