Class: Gitlab::Ci::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/config.rb,
lib/gitlab/ci/config/entry/job.rb,
lib/gitlab/ci/config/entry/key.rb,
lib/gitlab/ci/config/entry/jobs.rb,
lib/gitlab/ci/config/entry/need.rb,
lib/gitlab/ci/config/entry/port.rb,
lib/gitlab/ci/config/entry/root.rb,
lib/gitlab/ci/config/extendable.rb,
lib/gitlab/ci/config/normalizer.rb,
lib/gitlab/ci/config/entry/cache.rb,
lib/gitlab/ci/config/entry/files.rb,
lib/gitlab/ci/config/entry/image.rb,
lib/gitlab/ci/config/entry/needs.rb,
lib/gitlab/ci/config/entry/paths.rb,
lib/gitlab/ci/config/entry/ports.rb,
lib/gitlab/ci/config/entry/retry.rb,
lib/gitlab/ci/config/entry/rules.rb,
lib/gitlab/ci/config/entry/stage.rb,
lib/gitlab/ci/config/entry/bridge.rb,
lib/gitlab/ci/config/entry/hidden.rb,
lib/gitlab/ci/config/entry/policy.rb,
lib/gitlab/ci/config/entry/prefix.rb,
lib/gitlab/ci/config/entry/script.rb,
lib/gitlab/ci/config/entry/stages.rb,
lib/gitlab/ci/config/entry/default.rb,
lib/gitlab/ci/config/entry/include.rb,
lib/gitlab/ci/config/entry/inherit.rb,
lib/gitlab/ci/config/entry/release.rb,
lib/gitlab/ci/config/entry/reports.rb,
lib/gitlab/ci/config/entry/service.rb,
lib/gitlab/ci/config/entry/timeout.rb,
lib/gitlab/ci/config/entry/trigger.rb,
lib/gitlab/ci/config/entry/commands.rb,
lib/gitlab/ci/config/entry/coverage.rb,
lib/gitlab/ci/config/entry/includes.rb,
lib/gitlab/ci/config/entry/services.rb,
lib/gitlab/ci/config/entry/workflow.rb,
lib/gitlab/ci/config/entry/artifacts.rb,
lib/gitlab/ci/config/entry/variables.rb,
lib/gitlab/ci/config/external/mapper.rb,
lib/gitlab/ci/config/entry/kubernetes.rb,
lib/gitlab/ci/config/entry/rules/rule.rb,
lib/gitlab/ci/config/extendable/entry.rb,
lib/gitlab/ci/config/external/context.rb,
lib/gitlab/ci/config/entry/environment.rb,
lib/gitlab/ci/config/entry/processable.rb,
lib/gitlab/ci/config/external/file/base.rb,
lib/gitlab/ci/config/external/processor.rb,
lib/gitlab/ci/config/normalizer/factory.rb,
lib/gitlab/ci/config/external/file/local.rb,
lib/gitlab/ci/config/edge_stages_injector.rb,
lib/gitlab/ci/config/entry/product/matrix.rb,
lib/gitlab/ci/config/entry/release/assets.rb,
lib/gitlab/ci/config/external/file/remote.rb,
lib/gitlab/ci/config/entry/inherit/default.rb,
lib/gitlab/ci/config/external/file/project.rb,
lib/gitlab/ci/config/entry/product/parallel.rb,
lib/gitlab/ci/config/external/file/artifact.rb,
lib/gitlab/ci/config/external/file/template.rb,
lib/gitlab/ci/config/entry/inherit/variables.rb,
lib/gitlab/ci/config/entry/product/variables.rb,
lib/gitlab/ci/config/entry/release/assets/link.rb,
lib/gitlab/ci/config/entry/release/assets/links.rb,
lib/gitlab/ci/config/normalizer/matrix_strategy.rb,
lib/gitlab/ci/config/normalizer/number_strategy.rb

Overview

Base GitLab CI Configuration facade

Defined Under Namespace

Modules: Entry, External Classes: EdgeStagesInjector, Extendable, Normalizer

Constant Summary collapse

ConfigError =
Class.new(StandardError)
TIMEOUT_SECONDS =
30.seconds
TIMEOUT_MESSAGE =
'Resolving config took longer than expected'
RESCUE_ERRORS =
[
  Gitlab::Config::Loader::FormatError,
  Extendable::ExtensionError,
  External::Processor::IncludeError
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, project: nil, sha: nil, user: nil, parent_pipeline: nil) ⇒ Config

Returns a new instance of Config.


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

def initialize(config, project: nil, sha: nil, user: nil, parent_pipeline: nil)
  @context = build_context(project: project, sha: sha, user: user, parent_pipeline: parent_pipeline)
  @context.set_deadline(TIMEOUT_SECONDS)

  @config = expand_config(config)

  @root = Entry::Root.new(@config)
  @root.compose!

rescue *rescue_errors => e
  raise Config::ConfigError, e.message
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root


19
20
21
# File 'lib/gitlab/ci/config.rb', line 19

def root
  @root
end

Instance Method Details

#errorsObject


38
39
40
# File 'lib/gitlab/ci/config.rb', line 38

def errors
  @root.errors
end

#jobsObject


65
66
67
# File 'lib/gitlab/ci/config.rb', line 65

def jobs
  root.jobs_value
end

#normalized_jobsObject


69
70
71
# File 'lib/gitlab/ci/config.rb', line 69

def normalized_jobs
  @normalized_jobs ||= Ci::Config::Normalizer.new(jobs).normalize_jobs
end

#stagesObject


61
62
63
# File 'lib/gitlab/ci/config.rb', line 61

def stages
  root.stages_value
end

#to_hashObject


46
47
48
# File 'lib/gitlab/ci/config.rb', line 46

def to_hash
  @config
end

#valid?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'lib/gitlab/ci/config.rb', line 34

def valid?
  @root.valid?
end

#variablesObject

Temporary method that should be removed after refactoring


53
54
55
# File 'lib/gitlab/ci/config.rb', line 53

def variables
  root.variables_value
end

#variables_with_dataObject


57
58
59
# File 'lib/gitlab/ci/config.rb', line 57

def variables_with_data
  root.variables_entry.value_with_data
end

#warningsObject


42
43
44
# File 'lib/gitlab/ci/config.rb', line 42

def warnings
  @root.warnings
end