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

46 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
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 configuration of Docker services.
#
2019-02-15 15:39:39 +05:30
class Services < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
2016-08-24 12:49:21 +05:30
validations do
2017-09-10 17:25:29 +05:30
validates :config, type: Array
2019-07-07 11:18:12 +05:30
validates :config, services_with_ports_alias_unique: true, if: ->(record) { record.opt(:with_image_ports) }
2017-09-10 17:25:29 +05:30
end
def compose!(deps = nil)
super do
@entries = []
@config.each do |config|
2019-02-15 15:39:39 +05:30
@entries << ::Gitlab::Config::Entry::Factory.new(Entry::Service)
2017-09-10 17:25:29 +05:30
.value(config || {})
2019-07-07 11:18:12 +05:30
.with(key: "service", parent: self, description: "service definition.") # rubocop:disable CodeReuse/ActiveRecord
2017-09-10 17:25:29 +05:30
.create!
end
@entries.each do |entry|
entry.compose!(deps)
end
end
end
def value
@entries.map(&:value)
end
def descendants
@entries
2016-08-24 12:49:21 +05:30
end
end
end
end
end
end