Class: Eien::Domains::UpdateTask

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

Constant Summary collapse

ALLOWED_ATTRIBUTES =
[:enabled, :name].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/domains/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/domains/update_task.rb', line 8

def app
  @app
end

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#domainObject (readonly)

Returns the value of attribute domain.



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

def domain
  @domain
end

Instance Method Details

#run!Object



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

def run!
  client = kubeclient_builder.build_eien_kubeclient(context)
  domains = client.get_domains(namespace: app.spec.namespace)
  domains.map do |domain_resource|
    domain_resource.spec = (domain_resource.spec&.to_h || {}).merge(attributes)

    client.update_domain(domain_resource)
  end
end