debian-mirror-gitlab/lib/gitlab/ci/config/entry/image.rb

47 lines
967 B
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05:30
module Gitlab
module Ci
class Config
2017-08-17 22:00:37 +05:30
module Entry
2016-08-24 12:49:21 +05:30
##
# Entry that represents a Docker image.
#
2017-08-17 22:00:37 +05:30
class Image < Node
2016-08-24 12:49:21 +05:30
include Validatable
2017-09-10 17:25:29 +05:30
ALLOWED_KEYS = %i[name entrypoint].freeze
2016-08-24 12:49:21 +05:30
validations do
2017-09-10 17:25:29 +05:30
validates :config, hash_or_string: true
validates :config, allowed_keys: ALLOWED_KEYS
validates :name, type: String, presence: true
validates :entrypoint, array_of_strings: true, allow_nil: true
end
def hash?
@config.is_a?(Hash)
end
def string?
@config.is_a?(String)
end
def name
value[:name]
end
def entrypoint
value[:entrypoint]
end
def value
return { name: @config } if string?
return @config if hash?
{}
2016-08-24 12:49:21 +05:30
end
end
end
end
end
end