Module: UffizziCore::ComposeFile::VariablesService

Included in:
ServicesOptions::EnvironmentService
Defined in:
app/services/uffizzi_core/compose_file/variables_service.rb

Instance Method Summary collapse

Instance Method Details

#build_variable(name, value) ⇒ Object



17
18
19
20
21
22
23
24
# File 'app/services/uffizzi_core/compose_file/variables_service.rb', line 17

def build_variable(name, value)
  raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.no_variable_name', name: name, value: value) if name.blank?

  {
    name: name,
    value: value,
  }
end

#parse_variable_from_array(arr) ⇒ Object



10
11
12
13
14
15
# File 'app/services/uffizzi_core/compose_file/variables_service.rb', line 10

def parse_variable_from_array(arr)
  name = arr.first.to_s
  value = arr.last.to_s

  build_variable(name, value)
end

#parse_variable_from_string(str) ⇒ Object



4
5
6
7
8
# File 'app/services/uffizzi_core/compose_file/variables_service.rb', line 4

def parse_variable_from_string(str)
  variable_parts = str.split('=', 2)

  parse_variable_from_array(variable_parts)
end