2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Config
|
2017-08-17 22:00:37 +05:30
|
|
|
module Entry
|
2016-08-24 12:49:21 +05:30
|
|
|
##
|
|
|
|
# Entry that represents a cache configuration
|
|
|
|
#
|
2019-02-15 15:39:39 +05:30
|
|
|
class Cache < ::Gitlab::Config::Entry::Node
|
|
|
|
include ::Gitlab::Config::Entry::Configurable
|
|
|
|
include ::Gitlab::Config::Entry::Attributable
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
ALLOWED_KEYS = %i[key untracked paths policy].freeze
|
2019-12-04 20:38:33 +05:30
|
|
|
DEFAULT_POLICY = 'pull-push'
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
validations do
|
|
|
|
validates :config, allowed_keys: ALLOWED_KEYS
|
2017-09-10 17:25:29 +05:30
|
|
|
validates :policy, inclusion: { in: %w[pull-push push pull], message: 'should be pull-push, push, or pull' }, allow_blank: true
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
entry :key, Entry::Key,
|
2016-08-24 12:49:21 +05:30
|
|
|
description: 'Cache key used to define a cache affinity.'
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
entry :untracked, ::Gitlab::Config::Entry::Boolean,
|
2016-08-24 12:49:21 +05:30
|
|
|
description: 'Cache all untracked files.'
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
entry :paths, Entry::Paths,
|
2016-08-24 12:49:21 +05:30
|
|
|
description: 'Specify which paths should be cached across builds.'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
attributes :policy
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def value
|
2017-09-10 17:25:29 +05:30
|
|
|
result = super
|
|
|
|
|
|
|
|
result[:key] = key_value
|
|
|
|
result[:policy] = policy || DEFAULT_POLICY
|
|
|
|
|
|
|
|
result
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|