Class: EnvVariablesService

Inherits:
Object
  • Object
show all
Defined in:
lib/uffizzi/services/env_variables_service.rb

Class Method Summary collapse

Class Method Details

.substitute_env_variables(compose_file_data) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/uffizzi/services/env_variables_service.rb', line 9

def substitute_env_variables(compose_file_data)
  compose_file_data.gsub(/\${1,2}\{?([?:\-_A-Za-z0-9]+)\}?/) do |variable|
    next variable if variable.start_with?('$$')

    variable_content = variable.match(/[?:\-_A-Za-z0-9]+/).to_s
    fetch_variable_value(variable_content)
  end
end