Class: Eclair::K8sItem
- Inherits:
-
Item
- Object
- Item
- Eclair::K8sItem
show all
- Defined in:
- lib/eclair/providers/k8s/k8s_item.rb
Instance Attribute Summary collapse
Attributes inherited from Item
#selected, #visible
Instance Method Summary
collapse
Methods inherited from Item
#select, #title, #toggle_select
#config
Constructor Details
#initialize(pod) ⇒ K8sItem
Returns a new instance of K8sItem.
10
11
12
13
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 10
def initialize pod
super()
@pod = pod
end
|
Instance Attribute Details
#pod ⇒ Object
Returns the value of attribute pod.
8
9
10
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 8
def pod
@pod
end
|
Instance Method Details
#color ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 19
def color
if @selected
[Curses::COLOR_YELLOW, -1, Curses::A_BOLD]
elsif !connectable?
[Curses::COLOR_BLACK, -1, Curses::A_BOLD]
else
[Curses::COLOR_WHITE, -1]
end
end
|
#command ⇒ Object
33
34
35
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 33
def command
"kubectl exec --namespace #{namespace} -ti #{name} #{exec_command}"
end
|
#connectable? ⇒ Boolean
56
57
58
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 56
def connectable?
status == "running"
end
|
#exec_command ⇒ Object
29
30
31
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 29
def exec_command
@pod["metadata"]["labels"]["eclair_exec_command"] || "/bin/sh"
end
|
37
38
39
40
41
42
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 37
def
" \#{name}\n launched at \#{launch_time.to_time}\n EOS\nend\n"
|
#id ⇒ Object
15
16
17
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 15
def id
@pod["metadata"]["uid"]
end
|
#label ⇒ Object
44
45
46
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 44
def label
" - #{name} [#{launched_at}]"
end
|
#name ⇒ Object
52
53
54
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 52
def name
@pod["metadata"]["name"]
end
|
#namespace ⇒ Object
48
49
50
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 48
def namespace
@pod["metadata"]["namespace"]
end
|
#search_key ⇒ Object
60
61
62
|
# File 'lib/eclair/providers/k8s/k8s_item.rb', line 60
def search_key
name.downcase
end
|