service.rb 890 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4 5 6 7 8 9
module Gitlab
  module Ci
    class Config
      module Entry
        ##
        # Entry that represents a configuration of Docker service.
        #
10
        class Service < Image
11 12 13 14 15 16 17 18 19
          include Validatable

          ALLOWED_KEYS = %i[name entrypoint command alias].freeze

          validations do
            validates :config, hash_or_string: true
            validates :config, allowed_keys: ALLOWED_KEYS

            validates :name, type: String, presence: true
20 21
            validates :entrypoint, array_of_strings: true, allow_nil: true
            validates :command, array_of_strings: true, allow_nil: true
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
            validates :alias, type: String, allow_nil: true
          end

          def alias
            value[:alias]
          end

          def command
            value[:command]
          end
        end
      end
    end
  end
end