Class: Kdep::Dashboard::RolloutPanel

Inherits:
Panel
  • Object
show all
Defined in:
lib/kdep/dashboard/rollout_panel.rb

Instance Attribute Summary

Attributes inherited from Panel

#lines, #rect, #scroll_offset, #title

Instance Method Summary collapse

Methods inherited from Panel

#add_line, #initialize, #render, #scroll_down, #scroll_up, #update

Constructor Details

This class inherits a constructor from Kdep::Dashboard::Panel

Instance Method Details

#update_from_deployment(deployment_json) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kdep/dashboard/rollout_panel.rb', line 4

def update_from_deployment(deployment_json)
  spec = deployment_json["spec"] || {}
  status = deployment_json["status"] || {}

  desired = spec["replicas"] || 1
  updated = status["updatedReplicas"] || 0
  available = status["availableReplicas"] || 0
  ready = status["readyReplicas"] || 0

  percent = desired > 0 ? (updated * 100 / desired) : 0

  conditions = status["conditions"] || []
  progressing = conditions.find { |c| c["type"] == "Progressing" }
  failed = progressing && progressing["status"] == "False"
  message = progressing ? progressing["message"] : nil

  @rollout = {
    desired: desired,
    updated: updated,
    available: available,
    ready: ready,
    percent: percent,
    failed: failed,
    message: message,
  }

  build_lines
end