Class: UffizziCore::ComposeFile::Parsers::ConfigsParserService

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

Class Method Summary collapse

Class Method Details

.parse(configs_data) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/uffizzi_core/compose_file/parsers/configs_parser_service.rb', line 5

def parse(configs_data)
  return [] if configs_data.nil?

  raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.invalid_type', option: :configs) unless configs_data.is_a?(Hash)

  configs = []
  configs_data.each_pair do |config_name, config_data|
    if config_data['file'].blank?
      raise UffizziCore::ComposeFile::ParseError,
            I18n.t('compose.config_file_option_empty', config_name: config_name)
    end

    configs << {
      config_name: config_name,
      config_file: config_data['file'],
    }
  end

  configs
end