Class: Vidar::DeployStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/vidar/deploy_status.rb

Constant Summary collapse

INITIAL_SLEEP =
2
SLEEP =
10
MAX_TRIES =
30

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace:, filter: nil, max_tries: MAX_TRIES) ⇒ DeployStatus

Returns a new instance of DeployStatus.



9
10
11
12
13
# File 'lib/vidar/deploy_status.rb', line 9

def initialize(namespace:, filter: nil, max_tries: MAX_TRIES)
  @namespace = namespace
  @filter = filter
  @max_tries = max_tries
end

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



7
8
9
# File 'lib/vidar/deploy_status.rb', line 7

def filter
  @filter
end

#max_triesObject (readonly)

Returns the value of attribute max_tries.



7
8
9
# File 'lib/vidar/deploy_status.rb', line 7

def max_tries
  @max_tries
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



7
8
9
# File 'lib/vidar/deploy_status.rb', line 7

def namespace
  @namespace
end

Instance Method Details

#last_pod_setObject



49
50
51
# File 'lib/vidar/deploy_status.rb', line 49

def last_pod_set
  @pod_set
end

#pod_setObject



53
54
55
# File 'lib/vidar/deploy_status.rb', line 53

def pod_set
  @pod_set = K8s::PodSet.new(namespace:, filter:)
end

#success?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
# File 'lib/vidar/deploy_status.rb', line 43

def success?
  return false unless last_pod_set

  last_pod_set.success?
end

#wait_until_completedObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vidar/deploy_status.rb', line 29

def wait_until_completed
  tries = 0

  sleep(INITIAL_SLEEP)

  until pod_set.deployed?
    tries += 1
    sleep(SLEEP)
    if tries > max_tries
      break
    end
  end
end

#wait_until_upObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vidar/deploy_status.rb', line 15

def wait_until_up
  tries = 0

  sleep(INITIAL_SLEEP)

  until pod_set.any?
    tries += 1
    sleep(SLEEP)
    if tries > max_tries
      break
    end
  end
end