Class: Eien::Routes::CreateTask

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

Returns a new instance of CreateTask.



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

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.



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

def app
  @app
end

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/eien/routes/create_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
# File 'lib/eien/routes/create_task.rb', line 15

def run!
  client = kubeclient_builder.build_eien_kubeclient(context)

  route = Kubeclient::Resource.new(
    metadata: {
      name: name,
      namespace: app.spec.namespace,
      labels: {
        "#{::Eien::LABEL_PREFIX}/app": app..name,
      },
    },
    spec: attributes,
  )
  client.create_route(route)
end