diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-09 10:53:56 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-09 10:53:56 +0200 |
commit | 6a319fd28790228295de19d8c786d1a807f73376 (patch) | |
tree | 9c2bab1bd179576f4d46bf5adc7981ea9f23b982 /lib | |
parent | d9d5042fd9edf2abd662566ddc4c65b6a9bdbb08 (diff) | |
download | gitlab-ce-6a319fd28790228295de19d8c786d1a807f73376.tar.gz |
Make it possible configure Ci entry description
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config/node/configurable.rb | 21 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/entry.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/global.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/script.rb | 4 |
4 files changed, 18 insertions, 16 deletions
diff --git a/lib/gitlab/ci/config/node/configurable.rb b/lib/gitlab/ci/config/node/configurable.rb index 9c04a1cdc08..4b33fe025bb 100644 --- a/lib/gitlab/ci/config/node/configurable.rb +++ b/lib/gitlab/ci/config/node/configurable.rb @@ -11,14 +11,19 @@ module Gitlab private - def add_node(key, entry_class) + def add_node(key, metadata) + entry = create_entry(key, metadata[:class]) + entry.description = metadata[:description] + + @nodes[key] = entry + end + + def create_entry(key, entry_class) if @value.has_key?(key) - entry = entry_class.new(@value[key], @root, self) + entry_class.new(@value[key], @root, self) else - entry = Node::Null.new(nil, @root, self) + Node::Null.new(nil, @root, self) end - - @nodes[key] = entry end class_methods do @@ -26,8 +31,10 @@ module Gitlab private - def add_node(symbol, entry_class) - node = { symbol.to_sym => entry_class } + def add_node(symbol, entry_class, metadata) + node = { symbol.to_sym => + { class: entry_class, + description: metadata[:description] } } (@nodes ||= {}).merge!(node) end diff --git a/lib/gitlab/ci/config/node/entry.rb b/lib/gitlab/ci/config/node/entry.rb index bdef2af9ae1..bbe07d68b36 100644 --- a/lib/gitlab/ci/config/node/entry.rb +++ b/lib/gitlab/ci/config/node/entry.rb @@ -5,6 +5,8 @@ module Gitlab class Entry class InvalidError < StandardError; end + attr_accessor :description + def initialize(value, root = nil, parent = nil) @value = value @root = root @@ -78,10 +80,6 @@ module Gitlab def validate! raise NotImplementedError end - - def description - raise NotImplementedError - end end end end diff --git a/lib/gitlab/ci/config/node/global.rb b/lib/gitlab/ci/config/node/global.rb index 5a176ab5eaf..7411f8c863e 100644 --- a/lib/gitlab/ci/config/node/global.rb +++ b/lib/gitlab/ci/config/node/global.rb @@ -5,7 +5,8 @@ module Gitlab class Global < Entry include Configurable - add_node :before_script, Script + add_node :before_script, Script, + description: 'Script that will be executed before each job.' end end end diff --git a/lib/gitlab/ci/config/node/script.rb b/lib/gitlab/ci/config/node/script.rb index db635f6541f..34d18ad2781 100644 --- a/lib/gitlab/ci/config/node/script.rb +++ b/lib/gitlab/ci/config/node/script.rb @@ -5,10 +5,6 @@ module Gitlab class Script < Entry include ValidationHelpers - def description - 'Script that is executed before the one defined in a job.' - end - def value @value.join("\n") end |