diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-07-06 07:40:43 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-07-06 07:40:43 +0000 |
commit | 7f500acb5f38f0ae5d4e2d51e27b6257e0800c3d (patch) | |
tree | db122866e3a238c8246a33bc91d5cd91cc09354d /lib | |
parent | 6afe25ef336aca40b87cede499f8b8f5928129f6 (diff) | |
parent | 35f4a00f371ae60477bdbafe9f8274c8560320cb (diff) | |
download | gitlab-ce-7f500acb5f38f0ae5d4e2d51e27b6257e0800c3d.tar.gz |
Merge branch '33772-readonly-gitlab-ci-cache' into 'master'
Introduce cache policies for CI jobs
Closes #33772
See merge request !12483
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/cache.rb | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e9bad721f44..99eda3b0c4b 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -832,7 +832,7 @@ module API end class Cache < Grape::Entity - expose :key, :untracked, :paths + expose :key, :untracked, :paths, :policy end class Credentials < Grape::Entity 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 |