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
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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -42,6 +42,11 @@ describe Gitlab::Ci::Config::Node::Global do
expect(global.nodes.first)
.to be_an_instance_of Gitlab::Ci::Config::Node::Script
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
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