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
38
39
40
# File 'lib/gitlab/ci/build/image.rb', line 26

def initialize(image)
  case image
  when String
    @name = image
    @ports = []
  when Hash
    @alias = image[:alias]
    @command = image[:command]
    @entrypoint = image[:entrypoint]
    @name = image[:name]
    @ports = build_ports(image).select(&:valid?)
    @variables = build_variables(image)
    @pull_policy = image[:pull_policy]
  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

#pull_policyObject (readonly)

Returns the value of attribute pull_policy.



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

def pull_policy
  @pull_policy
end

#variablesObject (readonly)

Returns the value of attribute variables.



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

def variables
  @variables
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)


42
43
44
# File 'lib/gitlab/ci/build/image.rb', line 42

def valid?
  @name.present?
end