Module: Gitlab::Config::Entry::Configurable

Overview

This mixin is responsible for adding DSL, which purpose is to simplify the process of adding child nodes.

This can be used only if parent node is a configuration entry that holds a hash as a configuration value, for example:

job:

script: ...
artifacts: ...

Instance Method Summary collapse

Instance Method Details

#compose!(deps = nil) ⇒ Object


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gitlab/config/entry/configurable.rb', line 28

def compose!(deps = nil)
  return unless valid?

  super do
    self.class.nodes.each do |key, factory|
      # If we override the config type validation
      # we can end with different config types like String
      next unless config.is_a?(Hash)

      entry_create!(key, config[key])
    end

    yield if block_given?

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

#entry_create!(key, value) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


49
50
51
52
53
54
55
56
# File 'lib/gitlab/config/entry/configurable.rb', line 49

def entry_create!(key, value)
  factory = self.class
    .nodes[key]
    .value(value)
    .with(key: key, parent: self)

  entries[key] = factory.create!
end

#skip_config_hash_validation?Boolean

rubocop: enable CodeReuse/ActiveRecord

Returns:


59
60
61
# File 'lib/gitlab/config/entry/configurable.rb', line 59

def skip_config_hash_validation?
  false
end