blob: 629c17e6250b469bd1fd3d33df9ff38681645e97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
module Gitlab
module Ci
class Config
module Node
##
# Entry that represents an environment.
#
class Environment < Entry
include Validatable
validations do
validates :name, presence: true
validates :url,
length: { maximum: 255 },
allow_nil: true,
addressable_url: true
validate do
unless hash? || string?
errors.add(:config, 'should be a hash or a string')
end
end
end
def hash?
@config.is_a?(Hash)
end
def string?
@config.is_a?(String)
end
def name
case
when string? then @config
when hash? then @config[:name]
end
end
def url
@config[:url] if hash?
end
def value
case
when string? then { name: @config }
when hash? then @config
end
end
end
end
end
end
end
|