Module: Gitlab::Ci::Variables::Helpers
- Defined in:
- lib/gitlab/ci/variables/helpers.rb
Class Method Summary collapse
- .inherit_yaml_variables(from:, to:, inheritance:) ⇒ Object
- .merge_variables(current_vars, new_vars) ⇒ Object
- .transform_to_array(vars) ⇒ Object
Class Method Details
.inherit_yaml_variables(from:, to:, inheritance:) ⇒ Object
29 30 31 |
# File 'lib/gitlab/ci/variables/helpers.rb', line 29 def inherit_yaml_variables(from:, to:, inheritance:) merge_variables(apply_inheritance(from, inheritance), to) end |
.merge_variables(current_vars, new_vars) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/gitlab/ci/variables/helpers.rb', line 8 def merge_variables(current_vars, new_vars) return current_vars if new_vars.blank? current_vars = transform_to_array(current_vars) if current_vars.is_a?(Hash) new_vars = transform_to_array(new_vars) if new_vars.is_a?(Hash) (new_vars + current_vars).uniq { |var| var[:key] } end |
.transform_to_array(vars) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/ci/variables/helpers.rb', line 17 def transform_to_array(vars) return [] if vars.blank? vars.map do |key, data| if data.is_a?(Hash) { key: key.to_s, **data.except(:key) } else { key: key.to_s, value: data } end end end |