Class: Gitlab::Ci::YamlProcessor::Result
- Inherits:
-
Object
- Object
- Gitlab::Ci::YamlProcessor::Result
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/yaml_processor/result.rb
Instance Attribute Summary collapse
-
#ci_config ⇒ Object
readonly
Returns the value of attribute ci_config.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#root_variables ⇒ Object
readonly
Returns the value of attribute root_variables.
-
#root_variables_with_prefill_data ⇒ Object
readonly
Returns the value of attribute root_variables_with_prefill_data.
-
#stages ⇒ Object
readonly
Returns the value of attribute stages.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
-
#workflow_auto_cancel ⇒ Object
readonly
Returns the value of attribute workflow_auto_cancel.
-
#workflow_name ⇒ Object
readonly
Returns the value of attribute workflow_name.
-
#workflow_rules ⇒ Object
readonly
Returns the value of attribute workflow_rules.
Instance Method Summary collapse
- #builds ⇒ Object
- #clear_jobs! ⇒ Object
- #config_metadata ⇒ Object
- #included_components ⇒ Object
- #included_templates ⇒ Object
-
#initialize(ci_config: nil, errors: [], warnings: []) ⇒ Result
constructor
A new instance of Result.
- #stage_for(job_name) ⇒ Object
- #stages_attributes ⇒ Object
- #uses_input_rules? ⇒ Boolean
- #uses_inputs? ⇒ Boolean
- #uses_keyword?(keyword) ⇒ Boolean
- #uses_nested_keyword?(path) ⇒ Boolean
- #valid? ⇒ Boolean
- #yaml_variables_for(job_name) ⇒ Object
Constructor Details
#initialize(ci_config: nil, errors: [], warnings: []) ⇒ Result
Returns a new instance of Result.
16 17 18 19 20 21 22 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 16 def initialize(ci_config: nil, errors: [], warnings: []) @ci_config = ci_config @errors = errors || [] @warnings = warnings || [] assign_valid_attributes if valid? end |
Instance Attribute Details
#ci_config ⇒ Object (readonly)
Returns the value of attribute ci_config.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def ci_config @ci_config end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def errors @errors end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def jobs @jobs end |
#root_variables ⇒ Object (readonly)
Returns the value of attribute root_variables.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def root_variables @root_variables end |
#root_variables_with_prefill_data ⇒ Object (readonly)
Returns the value of attribute root_variables_with_prefill_data.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def root_variables_with_prefill_data @root_variables_with_prefill_data end |
#stages ⇒ Object (readonly)
Returns the value of attribute stages.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def stages @stages end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def warnings @warnings end |
#workflow_auto_cancel ⇒ Object (readonly)
Returns the value of attribute workflow_auto_cancel.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def workflow_auto_cancel @workflow_auto_cancel end |
#workflow_name ⇒ Object (readonly)
Returns the value of attribute workflow_name.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def workflow_name @workflow_name end |
#workflow_rules ⇒ Object (readonly)
Returns the value of attribute workflow_rules.
11 12 13 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 11 def workflow_rules @workflow_rules end |
Instance Method Details
#builds ⇒ Object
37 38 39 40 41 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 37 def builds jobs.map do |name, _| build_attributes(name) end end |
#clear_jobs! ⇒ Object
99 100 101 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 99 def clear_jobs! @jobs = {} end |
#config_metadata ⇒ Object
95 96 97 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 95 def @ci_config&. || {} end |
#included_components ⇒ Object
74 75 76 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 74 def included_components @ci_config.included_components end |
#included_templates ⇒ Object
43 44 45 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 43 def included_templates @included_templates ||= @ci_config.included_templates end |
#stage_for(job_name) ⇒ Object
91 92 93 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 91 def stage_for(job_name) jobs.dig(job_name, :stage) end |
#stages_attributes ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 28 def stages_attributes stages.uniq.map do |stage| seeds = stage_builds_attributes(stage) { name: stage, index: stages.index(stage), builds: seeds } end end |
#uses_input_rules? ⇒ Boolean
65 66 67 68 69 70 71 72 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 65 def uses_input_rules? return false unless @ci_config inputs = @ci_config.spec[:inputs] return false unless inputs.is_a?(Hash) inputs.values.any? { |input_spec| input_spec.is_a?(Hash) && input_spec.key?(:rules) } end |
#uses_inputs? ⇒ Boolean
59 60 61 62 63 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 59 def uses_inputs? return false unless @ci_config @ci_config.spec[:inputs].present? end |
#uses_keyword?(keyword) ⇒ Boolean
47 48 49 50 51 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 47 def uses_keyword?(keyword) jobs.values.any? do |job| job.key?(keyword) end end |
#uses_nested_keyword?(path) ⇒ Boolean
53 54 55 56 57 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 53 def uses_nested_keyword?(path) jobs.values.any? do |job| has_nested_key?(job, *path) end end |
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 24 def valid? errors.empty? end |
#yaml_variables_for(job_name) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 79 def yaml_variables_for(job_name) job = jobs[job_name] return [] unless job Gitlab::Ci::Variables::Helpers.inherit_yaml_variables( from: root_variables, to: job[:job_variables], inheritance: job.fetch(:root_variables_inheritance, true) ) end |