Class: Eien::Renderers::ServiceRenderer

Inherits:
Renderer
  • Object
show all
Defined in:
lib/eien/renderers/service_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::TimeHelpers

#summarize_age

Constructor Details

#initialize(service) ⇒ ServiceRenderer

Returns a new instance of ServiceRenderer.



8
9
10
11
# File 'lib/eien/renderers/service_renderer.rb', line 8

def initialize(service)
  @service = service
  super()
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



6
7
8
# File 'lib/eien/renderers/service_renderer.rb', line 6

def service
  @service
end

Instance Method Details

#renderObject



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

def render
  ports_message = service.spec.ports.each_with_object([]) do |port, lines|
    lines << "#{port.nodePort} -> #{port.port}/#{port.name} -> #{port.targetPort}"
  end.join("\n")

  rows = [
    ["name", ColorizedString.new(name).light_magenta],
    ["", ""],
    ["created", "#{summarize_age(created_at)} ago"],
    ["", ""],
    ["cluster IP", service.spec.clusterIP],
    ["", ""],
    ["ports", ports_message],
    ["", ""],
    ["external IP", external_ip_status(service)],
  ]
  TTY::Table.new(rows).render(:unicode, multiline: true, padding: [0, 1])
end