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

39 lines
1.1 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module Gitlab
module Ci
class Config
module Entry
##
# Entry that represents a configuration of Docker service.
#
class Service < Image
2019-02-15 15:39:39 +05:30
include ::Gitlab::Config::Entry::Validatable
2017-09-10 17:25:29 +05:30
2019-05-18 00:54:41 +05:30
ALLOWED_KEYS = %i[name entrypoint command alias ports].freeze
2017-09-10 17:25:29 +05:30
validations do
validates :config, hash_or_string: true
validates :config, allowed_keys: ALLOWED_KEYS
2019-05-18 00:54:41 +05:30
validates :config, disallowed_keys: %i[ports], unless: :with_image_ports?
2017-09-10 17:25:29 +05:30
validates :name, type: String, presence: true
validates :entrypoint, array_of_strings: true, allow_nil: true
validates :command, array_of_strings: true, allow_nil: true
validates :alias, type: String, allow_nil: true
2019-05-18 00:54:41 +05:30
validates :alias, type: String, presence: true, unless: ->(record) { record.ports.blank? }
2017-09-10 17:25:29 +05:30
end
def alias
value[:alias]
end
def command
value[:command]
end
end
end
end
end
end