Class: Ufo::Docker::Pusher

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/ufo/docker/pusher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#default_cluster, #default_params, #display_params, #execute, #pretty_time, #settings

Constructor Details

#initialize(image, options) ⇒ Pusher

Returns a new instance of Pusher.



9
10
11
12
# File 'lib/ufo/docker/pusher.rb', line 9

def initialize(image, options)
  @options = options
  @last_image_name = image || full_image_name
end

Instance Attribute Details

#last_image_nameObject (readonly)

Returns the value of attribute last_image_name.



8
9
10
# File 'lib/ufo/docker/pusher.rb', line 8

def last_image_name
  @last_image_name
end

Instance Method Details

#builderObject



34
35
36
# File 'lib/ufo/docker/pusher.rb', line 34

def builder
  @builder ||= Builder.new(@options.merge(image: last_image_name))
end

#image_nameObject

full_image - does not include the tag



45
46
47
# File 'lib/ufo/docker/pusher.rb', line 45

def image_name
  settings["image"]
end

#pushObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ufo/docker/pusher.rb', line 14

def push
  update_auth_token
  start_time = Time.now
  message = "Pushed #{last_image_name} docker image."
  if @options[:noop]
    message = "NOOP #{message}"
  else
    command = "docker push #{last_image_name}"
    puts "=> #{command}".colorize(:green)
    success = execute(command, use_system: true)
    unless success
      puts "ERROR: The docker image fail to push.".colorize(:red)
      exit 1
    end
  end
  took = Time.now - start_time
  message << " Took #{pretty_time(took)}.".green
  puts message unless @options[:mute]
end

#update_auth_tokenObject



38
39
40
41
42
# File 'lib/ufo/docker/pusher.rb', line 38

def update_auth_token
  auth = Ufo::Ecr::Auth.new(last_image_name)
  # wont update auth token unless the image being pushed in the ECR image format
  auth.update if auth.ecr_image?
end