Class: Eien::Routes::ListTask

Inherits:
Task
  • Object
show all
Defined in:
lib/eien/routes/list_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) ⇒ ListTask

Returns a new instance of ListTask.



8
9
10
11
# File 'lib/eien/routes/list_task.rb', line 8

def initialize(context, app)
  @app = app
  super(context)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



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

def app
  @app
end

Instance Method Details

#run!Object



13
14
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
# File 'lib/eien/routes/list_task.rb', line 13

def run!
  the_app = Eien.app_from_name(context, app)
  client = kubeclient_builder.build_eien_kubeclient(context)
  routees = client.get_routes(namespace: the_app.spec.namespace)
  table = TTY::Table.new(
    [
      colorize("NAME").yellow,
      colorize("ENABLED").yellow,
      colorize("DOMAINS").yellow,
      colorize("PATH").yellow,
      colorize("PROCESS").yellow,
      colorize("PORT").yellow,
      colorize("AGE").yellow,
    ],
    routees.map do |route|
      [
        route..name,
        summarize_enabled(route.spec.enabled),
        summarize_domains(route.spec.domains),
        route.spec.path,
        route.spec.process,
        route.spec.port,
        summarize_age(Time.parse(route..creationTimestamp)),
      ]
    end,
  )

  output = table.render(:basic)
  puts output
end