Class: Gitlab::Ci::YamlProcessor::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/yaml_processor/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9

def errors
  @errors
end

#jobsObject (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_variablesObject (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_dataObject (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

#stagesObject (readonly)

Returns the value of attribute stages.



9
10
11
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 9

def stages
  @stages
end

#warningsObject (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_nameObject (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_rulesObject (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

#buildsObject



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_metadataObject



60
61
62
# File 'lib/gitlab/ci/yaml_processor/result.rb', line 60

def 
  @ci_config&. || {}
end

#included_templatesObject



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_attributesObject



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

Returns:

  • (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