summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/config/entry/cache.rb
diff options
context:
space:
mode:
authorHiroyuki Sato <sathiroyuki@gmail.com>2017-07-23 21:26:02 +0900
committerHiroyuki Sato <sathiroyuki@gmail.com>2017-07-23 21:26:02 +0900
commit9b25bbc45d4e6602452e230506601ff0ed8ba84a (patch)
tree95f7326e4162a325a5e7c7304c33f18194b52cbe /lib/gitlab/ci/config/entry/cache.rb
parent839018d2d4e3e899b1fa06a43d093a0fdceced42 (diff)
parentb92d5135d8522e1370636799d74b51f9a37d0b2f (diff)
downloadgitlab-ce-9b25bbc45d4e6602452e230506601ff0ed8ba84a.tar.gz
Merge branch 'master' into 1827-prevent-concurrent-editing-wiki
Conflicts: app/controllers/projects/wikis_controller.rb app/views/projects/wikis/edit.html.haml spec/features/projects/wiki/user_updates_wiki_page_spec.rb
Diffstat (limited to 'lib/gitlab/ci/config/entry/cache.rb')
-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