Class: UffizziCore::ComposeFile::Parsers::Services::HealthcheckParserService

Inherits:
Object
  • Object
show all
Defined in:
app/services/uffizzi_core/compose_file/parsers/services/healthcheck_parser_service.rb

Constant Summary collapse

REQUIRED_START_COMMANDS =
['NONE', 'CMD', 'CMD-SHELL'].freeze
REQUIRED_OPTIONS =
['test', 'disable'].freeze

Class Method Summary collapse

Class Method Details

.parse(healthcheck_data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/uffizzi_core/compose_file/parsers/services/healthcheck_parser_service.rb', line 8

def parse(healthcheck_data)
  return {} if healthcheck_data.blank?

  unless required_options_any?(healthcheck_data)
    raise UffizziCore::ComposeFile::ParseError,
          I18n.t('compose.healthcheck_missing_required_option',
                 required_options: REQUIRED_OPTIONS.join(', '))
  end

  command = parse_command(healthcheck_data) if healthcheck_data['test'].present?

  {
    test: command,
    interval: parse_time(:interval, healthcheck_data['interval']),
    timeout: parse_time(:timeout, healthcheck_data['timeout']),
    retries: parse_retries(healthcheck_data['retries']),
    start_period: parse_time(:start_period, healthcheck_data['start_period']),
    disable: parse_disable_option(healthcheck_data['disable'], command),
  }
end