Class: Gitlab::Ci::Config::Entry::Jobs

Inherits:
Gitlab::Config::Entry::Node show all
Includes:
Gitlab::Config::Entry::Validatable
Defined in:
lib/gitlab/ci/config/entry/jobs.rb

Overview

Entry that represents a set of jobs.

Constant Summary

Constants inherited from Gitlab::Config::Entry::Node

Gitlab::Config::Entry::Node::InvalidError

Instance Attribute Summary

Attributes inherited from Gitlab::Config::Entry::Node

#config, #default, #description, #key, #metadata, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Config::Entry::Validatable

#errors, included, #validate, #validator

Methods inherited from Gitlab::Config::Entry::Node

#[], #add_warning, #ancestors, aspects, default, #descendants, #errors, #hash?, #initialize, #inspect, #integer?, #leaf?, #location, #opt, #relevant?, #specified?, #string?, #valid?, #value, #warnings, with_aspect

Constructor Details

This class inherits a constructor from Gitlab::Config::Entry::Node

Class Method Details

.all_typesObject


43
44
45
# File 'lib/gitlab/ci/config/entry/jobs.rb', line 43

def self.all_types
  TYPES
end

.find_type(name, config) ⇒ Object


47
48
49
50
51
# File 'lib/gitlab/ci/config/entry/jobs.rb', line 47

def self.find_type(name, config)
  self.all_types.find do |type|
    type.matching?(name, config)
  end
end

Instance Method Details

#compose!(deps = nil) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/gitlab/ci/config/entry/jobs.rb', line 54

def compose!(deps = nil)
  super do
    @config.each do |name, config|
      node = self.class.find_type(name, config)
      next unless node

      factory = ::Gitlab::Config::Entry::Factory.new(node)
        .value(config || {})
        .(name: name)
        .with(key: name, parent: self,
              description: "#{name} job definition.")

      @entries[name] = factory.create!
    end

    @entries.each_value do |entry|
      entry.compose!(deps)
    end
  end
end