gitlab-org--gitlab-foss/lib/gitlab/ci/config/entry/cache.rb

46 lines
1.1 KiB
Ruby
Raw Normal View History

module Gitlab
module Ci
class Config
module Entry
##
# Entry that represents a cache configuration
#
class Cache < Node
include Configurable
2017-06-27 14:38:12 +00:00
include Attributable
2017-06-27 14:38:12 +00:00
ALLOWED_KEYS = %i[key untracked paths policy].freeze
DEFAULT_POLICY = 'pull-push'.freeze
validations do
validates :config, allowed_keys: ALLOWED_KEYS
2017-06-27 14:38:12 +00:00
validates :policy, inclusion: { in: %w[pull-push push pull], message: 'should be pull-push, push, or pull' }, allow_blank: true
end
entry :key, Entry::Key,
description: 'Cache key used to define a cache affinity.'
entry :untracked, Entry::Boolean,
description: 'Cache all untracked files.'
entry :paths, Entry::Paths,
description: 'Specify which paths should be cached across builds.'
helpers :key
2017-06-27 14:38:12 +00:00
attributes :policy
def value
2017-06-27 14:38:12 +00:00
result = super
result[:key] = key_value
result[:policy] = policy || DEFAULT_POLICY
result
end
end
end
end
end
end