diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-03-02 17:12:15 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-03-02 17:12:15 +0300 |
commit | 6e032d7ba0cd4ba7053f51dc4e14e0bd69d41217 (patch) | |
tree | a380ca012cc2f73841363a6210d1c798ebcd6f1a /lib/gitlab/ci/config | |
parent | bb062ebdb68e5d4d9a92339948ddaaa68cdcf36c (diff) |
Set default cache key for jobs, detail:
* Replace Unspecified with a field so that it's less surprising
* Define inspect for Node for easy debugging (and avoid building
a very huge string potentially from built-in inspect)
* Set default cache key to 'default'
Diffstat (limited to 'lib/gitlab/ci/config')
-rw-r--r-- | lib/gitlab/ci/config/entry/cache.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/factory.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/key.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/node.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/undefined.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/unspecified.rb | 19 |
6 files changed, 32 insertions, 24 deletions
diff --git a/lib/gitlab/ci/config/entry/cache.rb b/lib/gitlab/ci/config/entry/cache.rb index 066643ccfcc..4378768d0de 100644 --- a/lib/gitlab/ci/config/entry/cache.rb +++ b/lib/gitlab/ci/config/entry/cache.rb @@ -22,6 +22,16 @@ module Gitlab entry :paths, Entry::Paths, description: 'Specify which paths should be cached across builds.' + + helpers :key + + def self.default + { key: Entry::Key.default } + end + + def value + super.merge(key: key_value) + end end end end diff --git a/lib/gitlab/ci/config/entry/factory.rb b/lib/gitlab/ci/config/entry/factory.rb index 6be8288748f..3b6d10a5378 100644 --- a/lib/gitlab/ci/config/entry/factory.rb +++ b/lib/gitlab/ci/config/entry/factory.rb @@ -37,9 +37,7 @@ module Gitlab # See issue #18775. # if @value.nil? - Entry::Unspecified.new( - fabricate_unspecified - ) + fabricate_unspecified else fabricate(@entry, @value) end @@ -56,7 +54,7 @@ module Gitlab fabricate(Entry::Undefined) else fabricate(@entry, @entry.default) - end + end.tap(&:unspecify) end def fabricate(entry, value = nil) diff --git a/lib/gitlab/ci/config/entry/key.rb b/lib/gitlab/ci/config/entry/key.rb index 0e4c9fe6edc..f27ad0a7759 100644 --- a/lib/gitlab/ci/config/entry/key.rb +++ b/lib/gitlab/ci/config/entry/key.rb @@ -11,6 +11,10 @@ module Gitlab validations do validates :config, key: true end + + def self.default + 'default' + end end end end diff --git a/lib/gitlab/ci/config/entry/node.rb b/lib/gitlab/ci/config/entry/node.rb index 55a5447ab51..5c745babcb9 100644 --- a/lib/gitlab/ci/config/entry/node.rb +++ b/lib/gitlab/ci/config/entry/node.rb @@ -15,6 +15,7 @@ module Gitlab @config = config @metadata = metadata @entries = {} + @specified = true @validator = self.class.validator.new(self) @validator.validate(:new) @@ -62,14 +63,24 @@ module Gitlab end end + def unspecify + @specified = false + end + def specified? - true + @specified end def relevant? true end + def inspect + val = if leaf? then config else descendants end + unspecified = if specified? then '' else '(unspecified) ' end + "#<#{self.class.name} #{unspecified}{#{key}: #{val.inspect}}>" + end + def self.default end diff --git a/lib/gitlab/ci/config/entry/undefined.rb b/lib/gitlab/ci/config/entry/undefined.rb index b33b8238230..1171ac10f22 100644 --- a/lib/gitlab/ci/config/entry/undefined.rb +++ b/lib/gitlab/ci/config/entry/undefined.rb @@ -29,6 +29,10 @@ module Gitlab def relevant? false end + + def inspect + "#<#{self.class.name}>" + end end end end diff --git a/lib/gitlab/ci/config/entry/unspecified.rb b/lib/gitlab/ci/config/entry/unspecified.rb deleted file mode 100644 index fbb2551e870..00000000000 --- a/lib/gitlab/ci/config/entry/unspecified.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Gitlab - module Ci - class Config - module Entry - ## - # This class represents an unspecified entry. - # - # It decorates original entry adding method that indicates it is - # unspecified. - # - class Unspecified < SimpleDelegator - def specified? - false - end - end - end - end - end -end |