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

caches.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: 75240599c9c59aa6097deaab352897203b257959 (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
# frozen_string_literal: true

module Gitlab
  module Ci
    class Config
      module Entry
        ##
        # Entry that represents caches configuration
        #
        class Caches < ::Gitlab::Config::Entry::ComposableArray
          include ::Gitlab::Config::Entry::Validatable

          MULTIPLE_CACHE_LIMIT = 4

          validations do
            validate do
              unless config.is_a?(Hash) || config.is_a?(Array)
                errors.add(:config, 'can only be a Hash or an Array')
              end

              if config.is_a?(Array) && config.count > MULTIPLE_CACHE_LIMIT
                errors.add(:config, "no more than #{MULTIPLE_CACHE_LIMIT} caches can be created")
              end
            end
          end

          def initialize(*args)
            super

            @key = nil
          end

          def composable_class
            Entry::Cache
          end
        end
      end
    end
  end
end