Commit a0b96c07 authored by Stefano Tenuta's avatar Stefano Tenuta

Enabled variables for CI services

CI lint now validates the Services hash
even after adding a Variables hash

Variables are also returned in the Service object
when the runner requests a new Job

Changelog: added
parent 17c9a8fb
......@@ -6,6 +6,7 @@ module API
module JobRequest
class Service < Entities::Ci::JobRequest::Image
expose :alias, :command
expose :variables
end
end
end
......
......@@ -4,7 +4,7 @@ module Gitlab
module Ci
module Build
class Image
attr_reader :alias, :command, :entrypoint, :name, :ports
attr_reader :alias, :command, :entrypoint, :name, :ports, :variables
class << self
def from_image(job)
......@@ -33,6 +33,7 @@ module Gitlab
@entrypoint = image[:entrypoint]
@name = image[:name]
@ports = build_ports(image).select(&:valid?)
@variables = build_variables(image)
end
end
......@@ -45,6 +46,12 @@ module Gitlab
def build_ports(image)
image[:ports].to_a.map { |port| ::Gitlab::Ci::Build::Port.new(port) }
end
def build_variables(image)
image[:variables].to_a.map do |key, value|
{ key: key.to_s, value: value.to_s }
end
end
end
end
end
......
......@@ -15,7 +15,7 @@ module Gitlab
include ::Gitlab::Config::Entry::Attributable
include ::Gitlab::Config::Entry::Configurable
ALLOWED_KEYS = %i[name entrypoint command alias ports].freeze
ALLOWED_KEYS = %i[name entrypoint command alias ports variables].freeze
validations do
validates :config, hash_or_string: true
......@@ -32,6 +32,10 @@ module Gitlab
entry :ports, Entry::Ports,
description: 'Ports used to expose the service'
entry :variables, ::Gitlab::Ci::Config::Entry::Variables,
description: 'Environment variables available for this service.',
inherit: false
attributes :ports
def alias
......@@ -57,6 +61,10 @@ module Gitlab
{}
end
def variables
value[:variables]
end
def with_image_ports?
opt(:with_image_ports)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment