Class: Gitlab::Ci::Build::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/build/image.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ Image

Returns a new instance of Image.


26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gitlab/ci/build/image.rb', line 26

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

Instance Attribute Details

#aliasObject (readonly)

Returns the value of attribute alias


7
8
9
# File 'lib/gitlab/ci/build/image.rb', line 7

def alias
  @alias
end

#commandObject (readonly)

Returns the value of attribute command


7
8
9
# File 'lib/gitlab/ci/build/image.rb', line 7

def command
  @command
end

#entrypointObject (readonly)

Returns the value of attribute entrypoint


7
8
9
# File 'lib/gitlab/ci/build/image.rb', line 7

def entrypoint
  @entrypoint
end

#nameObject (readonly)

Returns the value of attribute name


7
8
9
# File 'lib/gitlab/ci/build/image.rb', line 7

def name
  @name
end

#portsObject (readonly)

Returns the value of attribute ports


7
8
9
# File 'lib/gitlab/ci/build/image.rb', line 7

def ports
  @ports
end

Class Method Details

.from_image(job) ⇒ Object


10
11
12
13
14
15
# File 'lib/gitlab/ci/build/image.rb', line 10

def from_image(job)
  image = Gitlab::Ci::Build::Image.new(job.options[:image])
  return unless image.valid?

  image
end

.from_services(job) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/gitlab/ci/build/image.rb', line 17

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

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/gitlab/ci/build/image.rb', line 39

def valid?
  @name.present?
end