Welcome to mirror list, hosted at ThFree Co, Russian Federation.

includes.rb « entry « config « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 24d0e27e3a775ec75413e1d5de10619c7bc29338 (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
33
34
35
36
37
38
39
40
41
# 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, array_or_string: true

            validate do
              next unless opt(:max_size)
              next unless config.is_a?(Array)

              if config.size > opt(:max_size)
                errors.add(:config, "is too long (maximum is #{opt(:max_size)})")
              end
            end
          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