summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-06-27 15:38:12 +0100
committerNick Thomas <nick@gitlab.com>2017-07-05 15:39:26 +0100
commit35f4a00f371ae60477bdbafe9f8274c8560320cb (patch)
treef52e80f87701e2a2724482b8705e97ac842bebc5 /lib/gitlab
parent98768953f31d9b4f243c52e4dd5579f21cb7976f (diff)
downloadgitlab-ce-35f4a00f371ae60477bdbafe9f8274c8560320cb.tar.gz
Introduce cache policies for CI jobs
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/ci/config/entry/cache.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/gitlab/ci/config/entry/cache.rb b/lib/gitlab/ci/config/entry/cache.rb
index f074df9c7a1..d7e09acbbf3 100644
--- a/lib/gitlab/ci/config/entry/cache.rb
+++ b/lib/gitlab/ci/config/entry/cache.rb
@@ -7,11 +7,14 @@ module Gitlab
#
class Cache < Node
include Configurable
+ include Attributable
- ALLOWED_KEYS = %i[key untracked paths].freeze
+ ALLOWED_KEYS = %i[key untracked paths policy].freeze
+ DEFAULT_POLICY = 'pull-push'.freeze
validations do
validates :config, allowed_keys: ALLOWED_KEYS
+ 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,
@@ -25,8 +28,15 @@ module Gitlab
helpers :key
+ attributes :policy
+
def value
- super.merge(key: key_value)
+ result = super
+
+ result[:key] = key_value
+ result[:policy] = policy || DEFAULT_POLICY
+
+ result
end
end
end