summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/entry/includes.rb
blob: 82b2b1ccf4b029db95f1d36ccbd13cfd6bac9e89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module Gitlab
  module Ci
    class Config
      module Entry
        ##
        # Entry that represents a list of include.
        #
        class Includes < ::Gitlab::Config::Entry::Node
          include ::Gitlab::Config::Entry::Validatable

          validations do
            validates :config, type: Array
          end

          def self.aspects
            super.append -> do
              @config = Array.wrap(@config)

              @config.each_with_index do |config, i|
                @entries[i] = ::Gitlab::Config::Entry::Factory.new(Entry::Include)
                                .value(config || {})
                                .create!
              end
            end
          end
        end
      end
    end
  end
end