Class: Eien::Domains::CreateTask

Inherits:
Task
  • Object
show all
Defined in:
lib/eien/domains/create_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, domain, **attributes) ⇒ CreateTask

Returns a new instance of CreateTask.



8
9
10
11
12
13
# File 'lib/eien/domains/create_task.rb', line 8

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

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



6
7
8
# File 'lib/eien/domains/create_task.rb', line 6

def app
  @app
end

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/eien/domains/create_task.rb', line 6

def attributes
  @attributes
end

#domainObject (readonly)

Returns the value of attribute domain.



6
7
8
# File 'lib/eien/domains/create_task.rb', line 6

def domain
  @domain
end

Instance Method Details

#run!Object



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

def run!
  client = kubeclient_builder.build_eien_kubeclient(context)

  domain = Kubeclient::Resource.new(
    metadata: {
      name: attributes[:name] || name_from_domain,
      namespace: app.spec.namespace,
      labels: {
        "#{::Eien::LABEL_PREFIX}/app": app..domain,
      },
    },
    spec: prepare_attributes,
  )

  client.create_domain(domain)
end