Commit 6a319fd2 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make it possible configure Ci entry description

parent d9d5042f
...@@ -11,14 +11,19 @@ module Gitlab ...@@ -11,14 +11,19 @@ module Gitlab
private 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) if @value.has_key?(key)
entry = entry_class.new(@value[key], @root, self) entry_class.new(@value[key], @root, self)
else else
entry = Node::Null.new(nil, @root, self) Node::Null.new(nil, @root, self)
end end
@nodes[key] = entry
end end
class_methods do class_methods do
...@@ -26,8 +31,10 @@ module Gitlab ...@@ -26,8 +31,10 @@ module Gitlab
private private
def add_node(symbol, entry_class) def add_node(symbol, entry_class, metadata)
node = { symbol.to_sym => entry_class } node = { symbol.to_sym =>
{ class: entry_class,
description: metadata[:description] } }
(@nodes ||= {}).merge!(node) (@nodes ||= {}).merge!(node)
end end
......
...@@ -5,6 +5,8 @@ module Gitlab ...@@ -5,6 +5,8 @@ module Gitlab
class Entry class Entry
class InvalidError < StandardError; end class InvalidError < StandardError; end
attr_accessor :description
def initialize(value, root = nil, parent = nil) def initialize(value, root = nil, parent = nil)
@value = value @value = value
@root = root @root = root
...@@ -78,10 +80,6 @@ module Gitlab ...@@ -78,10 +80,6 @@ module Gitlab
def validate! def validate!
raise NotImplementedError raise NotImplementedError
end end
def description
raise NotImplementedError
end
end end
end end
end end
......
...@@ -5,7 +5,8 @@ module Gitlab ...@@ -5,7 +5,8 @@ module Gitlab
class Global < Entry class Global < Entry
include Configurable include Configurable
add_node :before_script, Script add_node :before_script, Script,
description: 'Script that will be executed before each job.'
end end
end end
end end
......
...@@ -5,10 +5,6 @@ module Gitlab ...@@ -5,10 +5,6 @@ module Gitlab
class Script < Entry class Script < Entry
include ValidationHelpers include ValidationHelpers
def description
'Script that is executed before the one defined in a job.'
end
def value def value
@value.join("\n") @value.join("\n")
end end
......
...@@ -42,6 +42,11 @@ describe Gitlab::Ci::Config::Node::Global do ...@@ -42,6 +42,11 @@ describe Gitlab::Ci::Config::Node::Global do
expect(global.nodes.first) expect(global.nodes.first)
.to be_an_instance_of Gitlab::Ci::Config::Node::Script .to be_an_instance_of Gitlab::Ci::Config::Node::Script
end end
it 'sets correct description for nodes' do
expect(global.nodes.first.description)
.to eq 'Script that will be executed before each job.'
end
end end
describe '#has_config?' do describe '#has_config?' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment