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/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/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/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/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/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/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/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/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/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/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/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/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/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/interpolation/inputs/base_input.rb,
lib/gitlab/ci/config/interpolation/functions/truncate.rb,
lib/gitlab/ci/config/interpolation/inputs/array_input.rb,
lib/gitlab/ci/config/external/mapper/location_expander.rb,
lib/gitlab/ci/config/interpolation/inputs/number_input.rb,
lib/gitlab/ci/config/interpolation/inputs/string_input.rb,
lib/gitlab/ci/config/external/mapper/variables_expander.rb,
lib/gitlab/ci/config/interpolation/inputs/boolean_input.rb,
lib/gitlab/ci/config/interpolation/functions/expand_vars.rb
Overview
Base GitLab CI Configuration facade
Defined Under Namespace
Modules: Entry, External, FeatureFlags, Header, Interpolation, Yaml Classes: EdgeStagesInjector, Extendable, Normalizer
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) ⇒ Config
constructor
rubocop: disable Metrics/ParameterLists.
- #jobs ⇒ Object
- #metadata ⇒ Object
- #normalized_jobs ⇒ 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
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) ⇒ 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 |
# 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) @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) 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) 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
64 65 66 |
# File 'lib/gitlab/ci/config.rb', line 64 def errors @root.errors end |
#included_components ⇒ Object
138 139 140 |
# File 'lib/gitlab/ci/config.rb', line 138 def included_components @context.includes.filter_map { |i| i[:component] if i[:type] == :component }.uniq end |
#included_templates ⇒ Object
134 135 136 |
# File 'lib/gitlab/ci/config.rb', line 134 def included_templates @context.includes.filter_map { |i| i[:location] if i[:type] == :template } end |
#jobs ⇒ Object
106 107 108 109 110 |
# File 'lib/gitlab/ci/config.rb', line 106 def jobs Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.jobs_value end end |
#metadata ⇒ Object
142 143 144 145 146 147 |
# File 'lib/gitlab/ci/config.rb', line 142 def { includes: @context.includes, merged_yaml: @config&.deep_stringify_keys&.to_yaml } end |
#normalized_jobs ⇒ Object
130 131 132 |
# File 'lib/gitlab/ci/config.rb', line 130 def normalized_jobs @normalized_jobs ||= Ci::Config::Normalizer.new(jobs).normalize_jobs end |
#stages ⇒ Object
100 101 102 103 104 |
# File 'lib/gitlab/ci/config.rb', line 100 def stages Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.stages_value end end |
#to_hash ⇒ Object
72 73 74 |
# File 'lib/gitlab/ci/config.rb', line 72 def to_hash @config end |
#valid? ⇒ Boolean
rubocop: enable Metrics/ParameterLists
60 61 62 |
# File 'lib/gitlab/ci/config.rb', line 60 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:
81 82 83 84 85 |
# File 'lib/gitlab/ci/config.rb', line 81 def variables Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.variables_value end end |
#variables_with_data ⇒ Object
rubocop:enable Gitlab/NoCodeCoverageComment
88 89 90 91 92 |
# File 'lib/gitlab/ci/config.rb', line 88 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
94 95 96 97 98 |
# File 'lib/gitlab/ci/config.rb', line 94 def variables_with_prefill_data Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.variables_entry.value_with_prefill_data end end |
#warnings ⇒ Object
68 69 70 |
# File 'lib/gitlab/ci/config.rb', line 68 def warnings @root.warnings end |
#workflow_auto_cancel ⇒ Object
124 125 126 127 128 |
# File 'lib/gitlab/ci/config.rb', line 124 def workflow_auto_cancel Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.workflow_entry.auto_cancel_value end end |
#workflow_name ⇒ Object
118 119 120 121 122 |
# File 'lib/gitlab/ci/config.rb', line 118 def workflow_name Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.workflow_entry.name end end |
#workflow_rules ⇒ Object
112 113 114 115 116 |
# File 'lib/gitlab/ci/config.rb', line 112 def workflow_rules Gitlab::Ci::Config::FeatureFlags.with_actor(@project) do root.workflow_entry.rules_value end end |