Class: Gitlab::Config::Entry::Node
- Inherits:
-
Object
- Object
- Gitlab::Config::Entry::Node
show all
- Defined in:
- lib/gitlab/config/entry/node.rb
Overview
Base abstract class for each configuration entry node.
Direct Known Subclasses
Gitlab::Ci::Config::Entry::AllowFailure, Gitlab::Ci::Config::Entry::Artifacts, Gitlab::Ci::Config::Entry::AutoCancel, Gitlab::Ci::Config::Entry::Bridge, Gitlab::Ci::Config::Entry::Cache, Gitlab::Ci::Config::Entry::Cache::UnknownStrategy, Gitlab::Ci::Config::Entry::Commands, Gitlab::Ci::Config::Entry::Coverage, Gitlab::Ci::Config::Entry::Default, Gitlab::Ci::Config::Entry::Environment, Gitlab::Ci::Config::Entry::Files, Gitlab::Ci::Config::Entry::Hidden, Gitlab::Ci::Config::Entry::Hooks, Gitlab::Ci::Config::Entry::IdToken, Gitlab::Ci::Config::Entry::Image, Gitlab::Ci::Config::Entry::Include, Gitlab::Ci::Config::Entry::Include::Rules::Rule, Gitlab::Ci::Config::Entry::Inherit, Gitlab::Ci::Config::Entry::Inherit::Default::ArrayStrategy, Gitlab::Ci::Config::Entry::Inherit::Default::UnknownStrategy, Gitlab::Ci::Config::Entry::Inherit::Variables::ArrayStrategy, Gitlab::Ci::Config::Entry::Inherit::Variables::UnknownStrategy, Gitlab::Ci::Config::Entry::Job, Gitlab::Ci::Config::Entry::Key::ComplexKey, Gitlab::Ci::Config::Entry::Key::SimpleKey, Gitlab::Ci::Config::Entry::Key::UnknownStrategy, Gitlab::Ci::Config::Entry::Kubernetes, Gitlab::Ci::Config::Entry::Need::CrossPipelineDependency, Gitlab::Ci::Config::Entry::Need::JobHash, Gitlab::Ci::Config::Entry::Need::JobString, Gitlab::Ci::Config::Entry::Need::UnknownStrategy, Gitlab::Ci::Config::Entry::Pages, Gitlab::Ci::Config::Entry::Paths, Gitlab::Ci::Config::Entry::Policy::ComplexPolicy, Gitlab::Ci::Config::Entry::Policy::RefsPolicy, Gitlab::Ci::Config::Entry::Policy::UnknownStrategy, Gitlab::Ci::Config::Entry::Port, Gitlab::Ci::Config::Entry::Prefix, Gitlab::Ci::Config::Entry::Product::Matrix, Gitlab::Ci::Config::Entry::Product::Parallel::MatrixBuilds, Gitlab::Ci::Config::Entry::Product::Parallel::ParallelBuilds, Gitlab::Ci::Config::Entry::Product::Parallel::UnknownStrategy, Gitlab::Ci::Config::Entry::Product::Variables, Gitlab::Ci::Config::Entry::Publish, Gitlab::Ci::Config::Entry::PullPolicy, Gitlab::Ci::Config::Entry::Release, Gitlab::Ci::Config::Entry::Release::Assets, Gitlab::Ci::Config::Entry::Release::Assets::Link, Gitlab::Ci::Config::Entry::Release::Assets::Links, Gitlab::Ci::Config::Entry::Reports, Gitlab::Ci::Config::Entry::Reports::CoverageReport, Gitlab::Ci::Config::Entry::Retry::FullRetry, Gitlab::Ci::Config::Entry::Retry::SimpleRetry, Gitlab::Ci::Config::Entry::Retry::UnknownStrategy, Gitlab::Ci::Config::Entry::Root, Gitlab::Ci::Config::Entry::Rules::Rule, Gitlab::Ci::Config::Entry::Rules::Rule::Changes::ComplexChanges, Gitlab::Ci::Config::Entry::Rules::Rule::Changes::SimpleChanges, Gitlab::Ci::Config::Entry::Rules::Rule::Changes::UnknownStrategy, Gitlab::Ci::Config::Entry::Rules::Rule::Exists::ComplexExists, Gitlab::Ci::Config::Entry::Rules::Rule::Exists::SimpleExists, Gitlab::Ci::Config::Entry::Rules::Rule::Exists::UnknownStrategy, Gitlab::Ci::Config::Entry::Service, Gitlab::Ci::Config::Entry::Stage, Gitlab::Ci::Config::Entry::Stages, Gitlab::Ci::Config::Entry::Tags, Gitlab::Ci::Config::Entry::Timeout, Gitlab::Ci::Config::Entry::Trigger::ComplexTrigger::CrossProjectTrigger, Gitlab::Ci::Config::Entry::Trigger::ComplexTrigger::SameProjectTrigger, Gitlab::Ci::Config::Entry::Trigger::ComplexTrigger::UnknownStrategy, Gitlab::Ci::Config::Entry::Trigger::Forward, Gitlab::Ci::Config::Entry::Trigger::SimpleTrigger, Gitlab::Ci::Config::Entry::Trigger::UnknownStrategy, Gitlab::Ci::Config::Entry::Variable::ComplexVariable, Gitlab::Ci::Config::Entry::Variable::SimpleVariable, Gitlab::Ci::Config::Entry::Variable::UnknownStrategy, Gitlab::Ci::Config::Entry::Workflow, Gitlab::Ci::Config::Header::Input, Gitlab::Ci::Config::Header::Root, Gitlab::Ci::Config::Header::Spec, ArrayOfStrings, Boolean, ComposableArray, ComposableHash, Undefined, WebIde::Config::Entry::Global, WebIde::Config::Entry::Terminal
Constant Summary
collapse
- InvalidError =
Class.new(StandardError)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config, **metadata) {|_self| ... } ⇒ Node
Returns a new instance of Node.
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/gitlab/config/entry/node.rb', line 15
def initialize(config, **metadata)
@config = config
@metadata = metadata
@entries = {}
@warnings = []
yield(self) if block_given?
self.class.aspects.to_a.each do |aspect|
instance_exec(&aspect)
end
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12
13
14
|
# File 'lib/gitlab/config/entry/node.rb', line 12
def config
@config
end
|
#default ⇒ Object
Returns the value of attribute default.
13
14
15
|
# File 'lib/gitlab/config/entry/node.rb', line 13
def default
@default
end
|
#deprecation ⇒ Object
Returns the value of attribute deprecation.
13
14
15
|
# File 'lib/gitlab/config/entry/node.rb', line 13
def deprecation
@deprecation
end
|
#description ⇒ Object
Returns the value of attribute description.
13
14
15
|
# File 'lib/gitlab/config/entry/node.rb', line 13
def description
@description
end
|
#key ⇒ Object
Returns the value of attribute key.
13
14
15
|
# File 'lib/gitlab/config/entry/node.rb', line 13
def key
@key
end
|
Returns the value of attribute metadata.
12
13
14
|
# File 'lib/gitlab/config/entry/node.rb', line 12
def metadata
@metadata
end
|
#parent ⇒ Object
Returns the value of attribute parent.
13
14
15
|
# File 'lib/gitlab/config/entry/node.rb', line 13
def parent
@parent
end
|
Class Method Details
.aspects ⇒ Object
123
124
125
|
# File 'lib/gitlab/config/entry/node.rb', line 123
def self.aspects
@aspects ||= []
end
|
.default ⇒ Object
121
|
# File 'lib/gitlab/config/entry/node.rb', line 121
def self.default(**); end
|
.with_aspect(blk) ⇒ Object
127
128
129
|
# File 'lib/gitlab/config/entry/node.rb', line 127
def self.with_aspect(blk)
self.aspects.append(blk)
end
|
Instance Method Details
#[](key) ⇒ Object
28
29
30
|
# File 'lib/gitlab/config/entry/node.rb', line 28
def [](key)
@entries[key] || Entry::Undefined.new
end
|
#add_warning(message) ⇒ Object
68
69
70
|
# File 'lib/gitlab/config/entry/node.rb', line 68
def add_warning(message)
@warnings << "#{location} #{message}"
end
|
#ancestors ⇒ Object
46
47
48
|
# File 'lib/gitlab/config/entry/node.rb', line 46
def ancestors
@parent ? @parent.ancestors + [@parent] : []
end
|
109
110
111
|
# File 'lib/gitlab/config/entry/node.rb', line 109
def array?
@config.is_a?(Array)
end
|
#compose!(deps = nil) ⇒ Object
32
33
34
35
36
|
# File 'lib/gitlab/config/entry/node.rb', line 32
def compose!(deps = nil)
return unless valid?
yield if block_given?
end
|
#descendants ⇒ Object
42
43
44
|
# File 'lib/gitlab/config/entry/node.rb', line 42
def descendants
@entries.values
end
|
#errors ⇒ Object
60
61
62
|
# File 'lib/gitlab/config/entry/node.rb', line 60
def errors
[]
end
|
105
106
107
|
# File 'lib/gitlab/config/entry/node.rb', line 105
def hash?
@config.is_a?(Hash)
end
|
#inspect ⇒ Object
99
100
101
102
103
|
# File 'lib/gitlab/config/entry/node.rb', line 99
def inspect
val = leaf? ? config : descendants
unspecified = specified? ? '' : '(unspecified) '
"#<#{self.class.name} #{unspecified}{#{key}: #{val.inspect}}>"
end
|
117
118
119
|
# File 'lib/gitlab/config/entry/node.rb', line 117
def integer?
@config.is_a?(Integer)
end
|
38
39
40
|
# File 'lib/gitlab/config/entry/node.rb', line 38
def leaf?
@entries.none?
end
|
#location ⇒ Object
92
93
94
95
96
97
|
# File 'lib/gitlab/config/entry/node.rb', line 92
def location
name = @key.presence || self.class.name.to_s.demodulize
.underscore.humanize.downcase
ancestors.map(&:key).append(name).compact.join(':')
end
|
#opt(key) ⇒ Object
50
51
52
53
54
|
# File 'lib/gitlab/config/entry/node.rb', line 50
def opt(key)
opt = metadata[key]
opt = @parent.opt(key) if opt.nil? && @parent
opt
end
|
88
89
90
|
# File 'lib/gitlab/config/entry/node.rb', line 88
def relevant?
true
end
|
84
85
86
|
# File 'lib/gitlab/config/entry/node.rb', line 84
def specified?
true
end
|
113
114
115
|
# File 'lib/gitlab/config/entry/node.rb', line 113
def string?
@config.is_a?(String)
end
|
56
57
58
|
# File 'lib/gitlab/config/entry/node.rb', line 56
def valid?
errors.none?
end
|
#value ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/gitlab/config/entry/node.rb', line 72
def value
if leaf?
@config
else
meaningful = @entries.select do |_key, value|
value.specified? && value.relevant?
end
meaningful.transform_values { |entry| entry.value }
end
end
|
#warnings ⇒ Object
64
65
66
|
# File 'lib/gitlab/config/entry/node.rb', line 64
def warnings
@warnings + descendants.flat_map(&:warnings)
end
|