Class: Gitlab::Ci::Config::Yaml::Loader

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/config/yaml/loader.rb

Constant Summary collapse

AVAILABLE_TAGS =
[Config::Yaml::Tags::Reference].freeze
MAX_DOCUMENTS =
2

Instance Method Summary collapse

Constructor Details

#initialize(content, inputs: {}) ⇒ Loader

Returns a new instance of Loader.



13
14
15
16
# File 'lib/gitlab/ci/config/yaml/loader.rb', line 13

def initialize(content, inputs: {})
  @content = content
  @inputs = inputs
end

Instance Method Details

#loadObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/ci/config/yaml/loader.rb', line 18

def load
  yaml_result = load_uninterpolated_yaml

  return yaml_result unless yaml_result.valid?

  interpolator = Interpolation::Interpolator.new(yaml_result, inputs)

  interpolator.interpolate!

  if interpolator.valid?
    # This Result contains only the interpolated config and does not have a header
    Yaml::Result.new(config: interpolator.to_hash, error: nil, interpolated: interpolator.interpolated?)
  else
    Yaml::Result.new(error: interpolator.error_message, interpolated: interpolator.interpolated?)
  end
end