Class: Gitlab::Ci::Config
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/config.rb,
lib/gitlab/ci/config/yaml.rb,
lib/gitlab/ci/config/stages.rb,
lib/gitlab/ci/config/entry/job.rb,
lib/gitlab/ci/config/entry/key.rb,
lib/gitlab/ci/config/yaml/tags.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/entry/tags.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/hooks.rb,
lib/gitlab/ci/config/entry/image.rb,
lib/gitlab/ci/config/entry/needs.rb,
lib/gitlab/ci/config/entry/pages.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/header/root.rb,
lib/gitlab/ci/config/header/spec.rb,
lib/gitlab/ci/config/yaml/loader.rb,
lib/gitlab/ci/config/yaml/result.rb,
lib/gitlab/ci/config/entry/bridge.rb,
lib/gitlab/ci/config/entry/caches.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/stages.rb,
lib/gitlab/ci/config/header/input.rb,
lib/gitlab/ci/config/yaml/context.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/publish.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/feature_flags.rb,
lib/gitlab/ci/config/header/inputs.rb,
lib/gitlab/ci/config/entry/commands.rb,
lib/gitlab/ci/config/entry/coverage.rb,
lib/gitlab/ci/config/entry/id_token.rb,
lib/gitlab/ci/config/entry/includes.rb,
lib/gitlab/ci/config/entry/services.rb,
lib/gitlab/ci/config/entry/variable.rb,
lib/gitlab/ci/config/entry/workflow.rb,
lib/gitlab/ci/config/external/rules.rb,
lib/gitlab/ci/config/header/include.rb,
lib/gitlab/ci/config/yaml/documents.rb,
lib/gitlab/ci/config/yaml/tags/base.rb,
lib/gitlab/ci/config/entry/artifacts.rb,
lib/gitlab/ci/config/entry/imageable.rb,
lib/gitlab/ci/config/entry/job_input.rb,
lib/gitlab/ci/config/entry/variables.rb,
lib/gitlab/ci/config/external/mapper.rb,
lib/gitlab/ci/config/header/includes.rb,
lib/gitlab/ci/config/entry/base_input.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/header/component.rb,
lib/gitlab/ci/config/entry/auto_cancel.rb,
lib/gitlab/ci/config/entry/environment.rb,
lib/gitlab/ci/config/entry/processable.rb,
lib/gitlab/ci/config/entry/pull_policy.rb,
lib/gitlab/ci/config/external/file/base.rb,
lib/gitlab/ci/config/external/processor.rb,
lib/gitlab/ci/config/header/input/rules.rb,
lib/gitlab/ci/config/normalizer/factory.rb,
lib/gitlab/ci/config/yaml/tags/resolver.rb,
lib/gitlab/ci/config/entry/allow_failure.rb,
lib/gitlab/ci/config/entry/include/rules.rb,
lib/gitlab/ci/config/external/file/local.rb,
lib/gitlab/ci/config/interpolation/block.rb,
lib/gitlab/ci/config/yaml/tags/reference.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/external/mapper/base.rb,
lib/gitlab/ci/config/interpolation/access.rb,
lib/gitlab/ci/config/interpolation/config.rb,
lib/gitlab/ci/config/interpolation/inputs.rb,
lib/gitlab/ci/config/entry/inherit/default.rb,
lib/gitlab/ci/config/entry/trigger/forward.rb,
lib/gitlab/ci/config/external/file/project.rb,
lib/gitlab/ci/config/interpolation/context.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/external/header/mapper.rb,
lib/gitlab/ci/config/external/mapper/filter.rb,
lib/gitlab/ci/config/interpolation/template.rb,
lib/gitlab/ci/config/entry/inherit/variables.rb,
lib/gitlab/ci/config/entry/product/variables.rb,
lib/gitlab/ci/config/entry/rules/rule/exists.rb,
lib/gitlab/ci/config/external/file/component.rb,
lib/gitlab/ci/config/external/mapper/matcher.rb,
lib/gitlab/ci/config/header/input/rules/rule.rb,
lib/gitlab/ci/config/header/inputs/validator.rb,
lib/gitlab/ci/config/entry/include/rules/rule.rb,
lib/gitlab/ci/config/entry/rules/rule/changes.rb,
lib/gitlab/ci/config/external/mapper/verifier.rb,
lib/gitlab/ci/config/entry/release/assets/link.rb,
lib/gitlab/ci/config/external/header/processor.rb,
lib/gitlab/ci/config/entry/release/assets/links.rb,
lib/gitlab/ci/config/external/mapper/normalizer.rb,
lib/gitlab/ci/config/interpolation/interpolator.rb,
lib/gitlab/ci/config/normalizer/matrix_strategy.rb,
lib/gitlab/ci/config/normalizer/number_strategy.rb,
lib/gitlab/ci/config/entry/concerns/base_include.rb,
lib/gitlab/ci/config/entry/concerns/base_includes.rb,
lib/gitlab/ci/config/interpolation/functions/base.rb,
lib/gitlab/ci/config/entry/reports/coverage_report.rb,
lib/gitlab/ci/config/interpolation/functions_stack.rb,
lib/gitlab/ci/config/external/header/mapper/matcher.rb,
lib/gitlab/ci/config/interpolation/functions/truncate.rb,
lib/gitlab/ci/config/external/mapper/location_expander.rb,
lib/gitlab/ci/config/interpolation/matrix_interpolator.rb,
lib/gitlab/ci/config/external/mapper/variables_expander.rb,
lib/gitlab/ci/config/interpolation/functions/expand_vars.rb,
lib/gitlab/ci/config/interpolation/functions/posix_escape.rb
Overview
Base GitLab CI Configuration facade
Defined Under Namespace
Modules: Entry, External, FeatureFlags, Header, Interpolation, Yaml Classes: Extendable, Normalizer, Stages
Constant Summary collapse
- ConfigError =
Class.new(StandardError)
- TIMEOUT_SECONDS =
ENV.fetch('GITLAB_CI_CONFIG_FETCH_TIMEOUT_SECONDS', 30).to_i.clamp(0, 60).seconds
- TIMEOUT_MESSAGE =
'Request timed out when fetching configuration files.'- RESCUE_ERRORS =
[ Gitlab::Config::Loader::FormatError, Extendable::ExtensionError, External::Processor::IncludeError, Config::Yaml::Tags::TagError ].freeze
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#inject_edge_stages ⇒ Object
readonly
Returns the value of attribute inject_edge_stages.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#pipeline_policy_context ⇒ Object
readonly
Returns the value of attribute pipeline_policy_context.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_ref_path ⇒ Object
readonly
Returns the value of attribute source_ref_path.
Instance Method Summary collapse
- #errors ⇒ Object
- #included_components ⇒ Object
- #included_templates ⇒ Object
-
#initialize(config, project: nil, pipeline: nil, sha: nil, ref: nil, user: nil, parent_pipeline: nil, source: nil, pipeline_config: nil, logger: nil, inject_edge_stages: true, pipeline_policy_context: nil, inputs: {}) ⇒ Config
constructor
rubocop: disable Metrics/ParameterLists.
- #jobs ⇒ Object
- #metadata ⇒ Object
- #normalized_jobs ⇒ Object
- #normalizer_errors ⇒ Object
- #stages ⇒ Object
- #to_hash ⇒ Object
-
#valid? ⇒ Boolean
rubocop: enable Metrics/ParameterLists.
-
#variables ⇒ Object
Temporary method that should be removed after refactoring.
-
#variables_with_data ⇒ Object
:nocov: rubocop:enable Gitlab/NoCodeCoverageComment.
- #variables_with_prefill_data ⇒ Object
- #warnings ⇒ Object
- #workflow_auto_cancel ⇒ Object
- #workflow_name ⇒ Object
- #workflow_rules ⇒ Object
Constructor Details
#initialize(config, project: nil, pipeline: nil, sha: nil, ref: nil, user: nil, parent_pipeline: nil, source: nil, pipeline_config: nil, logger: nil, inject_edge_stages: true, pipeline_policy_context: nil, inputs: {}) ⇒ Config
rubocop: disable Metrics/ParameterLists
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gitlab/ci/config.rb', line 25 def initialize( config, project: nil, pipeline: nil, sha: nil, ref: nil, user: nil, parent_pipeline: nil, source: nil, pipeline_config: nil, logger: nil, inject_edge_stages: true, pipeline_policy_context: nil, inputs: {} ) @logger = logger || ::Gitlab::Ci::Pipeline::Logger.new(project: project) @source_ref_path = pipeline&.source_ref_path @project = project @inject_edge_stages = inject_edge_stages @pipeline_policy_context = pipeline_policy_context @context = self.logger.instrument(:config_build_context, once: true) do pipeline ||= ::Ci::Pipeline.new(project: project, sha: sha, ref: ref, user: user, source: source) build_context(project: project, pipeline: pipeline, sha: sha, user: user, parent_pipeline: parent_pipeline, pipeline_config: pipeline_config, pipeline_policy_context: pipeline_policy_context) end @context.set_deadline(TIMEOUT_SECONDS) @source = source Gitlab::Ci::Config::FeatureFlags.with_actor(project) do @config = self.logger.instrument(:config_expand, once: true) do (config, inputs) end @root = self.logger.instrument(:config_root, once: true) do Entry::Root.new(@config, project: project, user: user, logger: self.logger) end self.logger.instrument(:config_root_compose, once: true) do @root.compose! end end rescue *rescue_errors => e raise Config::ConfigError, e. end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
22 23 24 |
# File 'lib/gitlab/ci/config.rb', line 22 def context @context end |
#inject_edge_stages ⇒ Object (readonly)
Returns the value of attribute inject_edge_stages.
22 23 24 |
# File 'lib/gitlab/ci/config.rb', line 22 def inject_edge_stages @inject_edge_stages end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
22 23 24 |
# File 'lib/gitlab/ci/config.rb', line 22 def logger @logger end |
#pipeline_policy_context ⇒ Object (readonly)
Returns the value of attribute pipeline_policy_context.
22 23 24 |
# File 'lib/gitlab/ci/config.rb', line 22 def pipeline_policy_context @pipeline_policy_context end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
22 23 24 |
# File 'lib/gitlab/ci/config.rb', line 22 def root @root end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
22 23 24 |
# File 'lib/gitlab/ci/config.rb', line 22 def source @source end |
#source_ref_path ⇒ Object (readonly)
Returns the value of attribute source_ref_path.
22 23 24 |
# File 'lib/gitlab/ci/config.rb', line 22 def source_ref_path @source_ref_path end |
Instance Method Details
#errors ⇒ Object
68 69 70 |
# File 'lib/gitlab/ci/config.rb', line 68 def errors @root.errors end |
#included_components ⇒ Object
149 150 151 |
# File 'lib/gitlab/ci/config.rb', line 149 def included_components @context.includes.filter_map { |i| i[:component] if i[:type] == :component }.uniq end |
#included_templates ⇒ Object
145 146 147 |
# File 'lib/gitlab/ci/config.rb', line 145 def included_templates @context.includes.filter_map { |i| i[:location] if i[:type] == :template } end |
#jobs ⇒ Object
111 112 113 114 115 |
# File 'lib/gitlab/ci/config.rb', line 111 def jobs Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.jobs_value end end |
#metadata ⇒ Object
153 154 155 156 157 158 |
# File 'lib/gitlab/ci/config.rb', line 153 def { includes: @context.includes, merged_yaml: @config&.deep_stringify_keys&.to_yaml } end |
#normalized_jobs ⇒ Object
135 136 137 138 139 |
# File 'lib/gitlab/ci/config.rb', line 135 def normalized_jobs @normalized_jobs ||= Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do normalizer.normalize_jobs end end |
#normalizer_errors ⇒ Object
141 142 143 |
# File 'lib/gitlab/ci/config.rb', line 141 def normalizer_errors normalizer.errors end |
#stages ⇒ Object
105 106 107 108 109 |
# File 'lib/gitlab/ci/config.rb', line 105 def stages Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.stages_value end end |
#to_hash ⇒ Object
76 77 78 |
# File 'lib/gitlab/ci/config.rb', line 76 def to_hash @config end |
#valid? ⇒ Boolean
rubocop: enable Metrics/ParameterLists
64 65 66 |
# File 'lib/gitlab/ci/config.rb', line 64 def valid? @root.valid? end |
#variables ⇒ Object
Temporary method that should be removed after refactoring
rubocop:disable Gitlab/NoCodeCoverageComment – This is an existing method and probably never called :nocov:
85 86 87 88 89 |
# File 'lib/gitlab/ci/config.rb', line 85 def variables Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.variables_value end end |
#variables_with_data ⇒ Object
:nocov: rubocop:enable Gitlab/NoCodeCoverageComment
93 94 95 96 97 |
# File 'lib/gitlab/ci/config.rb', line 93 def variables_with_data Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.variables_entry.value_with_data end end |
#variables_with_prefill_data ⇒ Object
99 100 101 102 103 |
# File 'lib/gitlab/ci/config.rb', line 99 def variables_with_prefill_data Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.variables_entry.value_with_prefill_data end end |
#warnings ⇒ Object
72 73 74 |
# File 'lib/gitlab/ci/config.rb', line 72 def warnings @root.warnings end |
#workflow_auto_cancel ⇒ Object
129 130 131 132 133 |
# File 'lib/gitlab/ci/config.rb', line 129 def workflow_auto_cancel Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.workflow_entry.auto_cancel_value end end |
#workflow_name ⇒ Object
123 124 125 126 127 |
# File 'lib/gitlab/ci/config.rb', line 123 def workflow_name Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.workflow_entry.name end end |
#workflow_rules ⇒ Object
117 118 119 120 121 |
# File 'lib/gitlab/ci/config.rb', line 117 def workflow_rules Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.workflow_entry.rules_value end end |