Class: Gitlab::Ci::YamlProcessor::Result
- Inherits:
-
Object
- Object
- Gitlab::Ci::YamlProcessor::Result
- Defined in:
- lib/gitlab/ci/yaml_processor/result.rb
Instance Attribute Summary collapse
-
#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_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
- #config_metadata ⇒ 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
- #valid? ⇒ Boolean
- #yaml_variables_for(job_name) ⇒ Object
Constructor Details
#initialize(ci_config: nil, errors: [], warnings: []) ⇒ Result
Returns a new instance of Result.
14 15 16 17 18 19 20 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 14 def initialize(ci_config: nil, errors: [], warnings: []) @ci_config = ci_config @errors = errors || [] @warnings = warnings || [] assign_valid_attributes if valid? end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def errors @errors end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def jobs @jobs end |
#root_variables ⇒ Object (readonly)
Returns the value of attribute root_variables.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def root_variables @root_variables end |
#root_variables_with_prefill_data ⇒ Object (readonly)
Returns the value of attribute root_variables_with_prefill_data.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def root_variables_with_prefill_data @root_variables_with_prefill_data end |
#stages ⇒ Object (readonly)
Returns the value of attribute stages.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def stages @stages end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def warnings @warnings end |
#workflow_name ⇒ Object (readonly)
Returns the value of attribute workflow_name.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def workflow_name @workflow_name end |
#workflow_rules ⇒ Object (readonly)
Returns the value of attribute workflow_rules.
9 10 11 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9 def workflow_rules @workflow_rules end |
Instance Method Details
#builds ⇒ Object
34 35 36 37 38 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 34 def builds jobs.map do |name, _| build_attributes(name) end end |
#config_metadata ⇒ Object
60 61 62 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 60 def @ci_config&. || {} end |
#included_templates ⇒ Object
40 41 42 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 40 def included_templates @included_templates ||= @ci_config.included_templates end |
#stage_for(job_name) ⇒ Object
56 57 58 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 56 def stage_for(job_name) jobs.dig(job_name, :stage) end |
#stages_attributes ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 26 def stages_attributes stages.uniq.map do |stage| seeds = stage_builds_attributes(stage) { name: stage, index: stages.index(stage), builds: seeds } end end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 22 def valid? errors.empty? end |
#yaml_variables_for(job_name) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 44 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 |