Class: DockerTools::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_tools/dependency.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, registry, tag, fallback_tag) ⇒ Dependency

Returns a new instance of Dependency.



10
11
12
13
14
15
# File 'lib/docker_tools/dependency.rb', line 10

def initialize(name, registry, tag, fallback_tag)
  @name = name
  @registry = registry
  @tag = tag
  @fallback_tag = fallback_tag
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/docker_tools/dependency.rb', line 17

def run
  tag = @tag
  image = DockerTools::Image.new(@name, @registry, @tag)
  begin
    image.pull
  rescue
    puts "Falling back to image #{@registry}/#{@name}:#{@fallback_tag}"
    image = DockerTools::Image.new(@name, @registry, @fallback_tag)
    image.pull
    throw "Cannot find image" if image.image.nil?
    tag = @fallback_tag
  end
  tag
end