Class: Eien::Processes::UpdateTask

Inherits:
Task
  • Object
show all
Defined in:
lib/eien/processes/update_task.rb

Constant Summary collapse

ALLOWED_ATTRIBUTES =
[:enabled, :image, :config, :secret, :command, :replicas, :ports].freeze

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, **attributes) ⇒ UpdateTask

Returns a new instance of UpdateTask.



10
11
12
13
14
15
# File 'lib/eien/processes/update_task.rb', line 10

def initialize(context, app, name, **attributes)
  @app = Eien.app_from_name(context, app)
  @name = name
  @attributes = attributes
  super(context)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



8
9
10
# File 'lib/eien/processes/update_task.rb', line 8

def app
  @app
end

#attributesObject (readonly)

Returns the value of attribute attributes.



8
9
10
# File 'lib/eien/processes/update_task.rb', line 8

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/eien/processes/update_task.rb', line 8

def name
  @name
end

Instance Method Details

#run!Object



17
18
19
20
21
22
23
# File 'lib/eien/processes/update_task.rb', line 17

def run!
  client = kubeclient_builder.build_eien_kubeclient(context)
  the_process = client.get_process(name, app.spec.namespace)
  the_process.spec = (the_process.spec&.to_h || {}).merge(attributes)

  client.update_process(the_process)
end