Class: UffizziCore::ContainerService

Inherits:
Object
  • Object
show all
Defined in:
app/services/uffizzi_core/container_service.rb

Class Method Summary collapse

Class Method Details

.continuously_deploy_enabled?(container) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/services/uffizzi_core/container_service.rb', line 22

def continuously_deploy_enabled?(container)
  container.aasm(:continuously_deploy).current_state == UffizziCore::Container::STATE_CD_ENABLED
end

.defines_env?(container, name) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'app/services/uffizzi_core/container_service.rb', line 16

def defines_env?(container, name)
  return false if container.variables.nil?

  container.variables.select { |v| v['name'].downcase.to_sym == name.to_sym }.any?
end

.ingress_container?(container) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/services/uffizzi_core/container_service.rb', line 42

def ingress_container?(container)
  container.receive_incoming_requests?
end

.last_state(container) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/services/uffizzi_core/container_service.rb', line 26

def last_state(container)
  pods = pods_by_container(container)
  container_status = container_status(container, pods)
  return {} if container_status.blank? || container_status&.dig('last_state')&.blank?

  container_status['last_state'].map do |code, state|
    {
      code: code,
      reason: state.reason,
      exit_code: state.exit_code,
      started_at: state.started_at,
      finished_at: state.finished_at,
    }
  end.first
end

.pod_name(container) ⇒ Object



5
6
7
8
9
10
# File 'app/services/uffizzi_core/container_service.rb', line 5

def pod_name(container)
  return container.controller_name if container.controller_name.present?

  formatted_name = container.image_name
  formatted_name.parameterize.gsub('_', '-')
end

.target_port_value(container) ⇒ Object



12
13
14
# File 'app/services/uffizzi_core/container_service.rb', line 12

def target_port_value(container)
  container.port
end