Class: Kubecontrol::Resources::Pod
- Inherits:
-
Object
- Object
- Kubecontrol::Resources::Pod
- Defined in:
- lib/kubecontrol/resources/pod.rb
Constant Summary collapse
- RESOURCE_NAME =
'pods'.freeze
- RUNNING =
'Running'.freeze
Instance Attribute Summary collapse
-
#age ⇒ Object
readonly
Returns the value of attribute age.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#ready ⇒ Object
readonly
Returns the value of attribute ready.
-
#restarts ⇒ Object
readonly
Returns the value of attribute restarts.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #exec(command) ⇒ Object
-
#initialize(name, ready, status, restarts, age, namespace, client) ⇒ Pod
constructor
A new instance of Pod.
- #ready? ⇒ Boolean
- #running? ⇒ Boolean
- #stopped? ⇒ Boolean
Constructor Details
#initialize(name, ready, status, restarts, age, namespace, client) ⇒ Pod
Returns a new instance of Pod.
9 10 11 12 13 14 15 16 17 |
# File 'lib/kubecontrol/resources/pod.rb', line 9 def initialize(name, ready, status, restarts, age, namespace, client) @name = name @ready = ready @status = status @restarts = restarts @age = age @namespace = namespace @client = client end |
Instance Attribute Details
#age ⇒ Object (readonly)
Returns the value of attribute age.
7 8 9 |
# File 'lib/kubecontrol/resources/pod.rb', line 7 def age @age end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/kubecontrol/resources/pod.rb', line 7 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/kubecontrol/resources/pod.rb', line 7 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/kubecontrol/resources/pod.rb', line 7 def namespace @namespace end |
#ready ⇒ Object (readonly)
Returns the value of attribute ready.
7 8 9 |
# File 'lib/kubecontrol/resources/pod.rb', line 7 def ready @ready end |
#restarts ⇒ Object (readonly)
Returns the value of attribute restarts.
7 8 9 |
# File 'lib/kubecontrol/resources/pod.rb', line 7 def restarts @restarts end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/kubecontrol/resources/pod.rb', line 7 def status @status end |
Instance Method Details
#exec(command) ⇒ Object
32 33 34 |
# File 'lib/kubecontrol/resources/pod.rb', line 32 def exec(command) @client.kubectl_command("exec -i #{name} -- sh -c \"#{command.gsub('"', '\"')}\"") end |
#ready? ⇒ Boolean
27 28 29 30 |
# File 'lib/kubecontrol/resources/pod.rb', line 27 def ready? pod_containers = @ready.split('/').last @ready == "#{pod_containers}/#{pod_containers}" end |
#running? ⇒ Boolean
23 24 25 |
# File 'lib/kubecontrol/resources/pod.rb', line 23 def running? @status == RUNNING end |
#stopped? ⇒ Boolean
19 20 21 |
# File 'lib/kubecontrol/resources/pod.rb', line 19 def stopped? @status != RUNNING end |