Skip to content
Snippets Groups Projects
Commit 3fbfc30f authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Kamil Trzcińśki
Browse files

Fix CI job environment configuration entry class

parent 04b56955
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -11,20 +11,22 @@ module Gitlab
ALLOWED_KEYS = %i[name url]
 
validations do
validates :config, allowed_keys: ALLOWED_KEYS, if: :hash?
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
with_options if: :hash? do
validates :config, allowed_keys: ALLOWED_KEYS
validates :url,
length: { maximum: 255 },
addressable_url: true,
allow_nil: true
end
end
 
def hash?
Loading
Loading
@@ -44,9 +46,10 @@ module Gitlab
end
 
def value
case @config.type
case @config
when String then { name: @config }
when Hash then @config
else {}
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment