class Ufo::Docker::Pusher

Attributes

last_image_name[R]

Public Class Methods

new(image, options) click to toggle source
# File lib/ufo/docker/pusher.rb, line 9
def initialize(image, options)
  @options = options
  # full_image_name ultimately uses @options, so @last_image_name assignment
  # line must be defined after setting @options.
  @last_image_name = image || full_image_name
end

Public Instance Methods

builder() click to toggle source
# File lib/ufo/docker/pusher.rb, line 36
def builder
  @builder ||= Builder.new(@options.merge(image: last_image_name))
end
image_name() click to toggle source

full_image - does not include the tag

# File lib/ufo/docker/pusher.rb, line 47
def image_name
  settings[:image]
end
push() click to toggle source
# File lib/ufo/docker/pusher.rb, line 16
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}".color(:green)
    success = execute(command, use_system: true)
    unless success
      puts "ERROR: The docker image fail to push.".color(:red)
      exit 1
    end
  end
  took = Time.now - start_time
  message << "\nDocker push took #{pretty_time(took)}.".color(:green)
  puts message unless @options[:mute]
end
update_auth_token() click to toggle source
# File lib/ufo/docker/pusher.rb, line 40
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
end