diff options
author | Nick Thomas <nick@gitlab.com> | 2017-06-27 17:38:12 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-07-05 17:39:26 +0300 |
commit | 35f4a00f371ae60477bdbafe9f8274c8560320cb (patch) | |
tree | f52e80f87701e2a2724482b8705e97ac842bebc5 /lib/gitlab/ci/config | |
parent | 98768953f31d9b4f243c52e4dd5579f21cb7976f (diff) |
Introduce cache policies for CI jobs
Diffstat (limited to 'lib/gitlab/ci/config')
-rw-r--r-- | lib/gitlab/ci/config/entry/cache.rb | 14 |
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 |