summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/build/image.rb
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2019-04-03 09:50:54 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2019-04-03 09:50:54 +0000
commit6ee1d8cf7778ecef0997c10f22b18ab4b61e9b3b (patch)
treec3c33ae8baff308b7c3334829a804d532658c1b1 /lib/gitlab/ci/build/image.rb
parenta7d3a5e43957185dc6193d1b97c57fc4eb02e9ea (diff)
downloadgitlab-ce-6ee1d8cf7778ecef0997c10f22b18ab4b61e9b3b.tar.gz
Add port section to CI Image object
In order to implement https://gitlab.com/gitlab-org/gitlab-ee/issues/10179 we need several modifications on the CI config file. We are adding a new ports section in the default Image object. Each of these ports will accept: number, protocol and name. By default this new configuration will be only enabled in the Web IDE config file.
Diffstat (limited to 'lib/gitlab/ci/build/image.rb')
-rw-r--r--lib/gitlab/ci/build/image.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/ci/build/image.rb b/lib/gitlab/ci/build/image.rb
index 4dd932f61d4..1d7bfba75cd 100644
--- a/lib/gitlab/ci/build/image.rb
+++ b/lib/gitlab/ci/build/image.rb
@@ -4,7 +4,7 @@ module Gitlab
module Ci
module Build
class Image
- attr_reader :alias, :command, :entrypoint, :name
+ attr_reader :alias, :command, :entrypoint, :name, :ports
class << self
def from_image(job)
@@ -26,17 +26,25 @@ module Gitlab
def initialize(image)
if image.is_a?(String)
@name = image
+ @ports = []
elsif image.is_a?(Hash)
@alias = image[:alias]
@command = image[:command]
@entrypoint = image[:entrypoint]
@name = image[:name]
+ @ports = build_ports(image).select(&:valid?)
end
end
def valid?
@name.present?
end
+
+ private
+
+ def build_ports(image)
+ image[:ports].to_a.map { |port| ::Gitlab::Ci::Build::Port.new(port) }
+ end
end
end
end