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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.3 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.
#
2020-04-08 14:13:33 +05:30
class Service < ::Gitlab::Config::Entry::Node
2022-08-27 11:52:29 +05:30
include ::Gitlab::Ci::Config::Entry::Imageable
2017-09-10 17:25:29 +05:30
2022-08-27 11:52:29 +05:30
ALLOWED_KEYS = %i[command alias variables].freeze
2017-09-10 17:25:29 +05:30
validations do
2022-10-11 01:57:18 +05:30
validates :config, allowed_keys: ALLOWED_KEYS + IMAGEABLE_ALLOWED_KEYS
2017-09-10 17:25:29 +05:30
validates :command, array_of_strings: true, allow_nil: true
validates :alias, type: String, allow_nil: true
2019-07-07 11:18:12 +05:30
validates :alias, type: String, presence: true, unless: ->(record) { record.ports.blank? }
2017-09-10 17:25:29 +05:30
end
2021-12-11 22:18:48 +05:30
entry :variables, ::Gitlab::Ci::Config::Entry::Variables,
description: 'Environment variables available for this service.',
inherit: false
2022-08-27 11:52:29 +05:30
attributes :variables
2020-04-08 14:13:33 +05:30
2017-09-10 17:25:29 +05:30
def alias
value[:alias]
end
def command
value[:command]
end
2020-04-08 14:13:33 +05:30
def value
2022-08-13 15:12:31 +05:30
if string?
{ name: @config }
elsif hash?
@config.merge(
2022-10-11 01:57:18 +05:30
pull_policy: pull_policy_value
2022-08-13 15:12:31 +05:30
).compact
else
{}
end
2020-04-08 14:13:33 +05:30
end
2017-09-10 17:25:29 +05:30
end
end
end
end
end