2017-03-02 11:44:15 -05:00
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Build
|
|
|
|
class Image
|
2017-06-05 10:15:09 -04:00
|
|
|
attr_reader :alias, :command, :entrypoint, :name
|
2017-03-02 11:44:15 -05:00
|
|
|
|
|
|
|
class << self
|
|
|
|
def from_image(job)
|
|
|
|
image = Gitlab::Ci::Build::Image.new(job.options[:image])
|
|
|
|
return unless image.valid?
|
2017-11-14 04:02:39 -05:00
|
|
|
|
2017-03-02 11:44:15 -05:00
|
|
|
image
|
|
|
|
end
|
|
|
|
|
|
|
|
def from_services(job)
|
|
|
|
services = job.options[:services].to_a.map do |service|
|
|
|
|
Gitlab::Ci::Build::Image.new(service)
|
|
|
|
end
|
|
|
|
|
|
|
|
services.select(&:valid?).compact
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(image)
|
2017-06-05 10:15:09 -04:00
|
|
|
if image.is_a?(String)
|
|
|
|
@name = image
|
|
|
|
elsif image.is_a?(Hash)
|
|
|
|
@alias = image[:alias]
|
|
|
|
@command = image[:command]
|
|
|
|
@entrypoint = image[:entrypoint]
|
|
|
|
@name = image[:name]
|
|
|
|
end
|
2017-03-02 11:44:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
@name.present?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|