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_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

.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

.valid_memory_limit?(container) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'app/services/uffizzi_core/container_service.rb', line 26

def valid_memory_limit?(container)
  max_memory_limit = container.deployment.project..container_memory_limit
  container_memory_limit = container.memory_limit
  return true if max_memory_limit.nil? || container_memory_limit.nil?

  container_memory_limit <= max_memory_limit
end

.valid_memory_request?(container) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'app/services/uffizzi_core/container_service.rb', line 34

def valid_memory_request?(container)
  max_memory_limit = container.deployment.project..container_memory_limit
  container_memory_request = container.memory_request
  return true if max_memory_limit.nil? || container_memory_request.nil?

  container_memory_request <= max_memory_limit
end