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, #display_params, #execute, #pretty_time, #settings, #task_definition_arns, #user_params

Constructor Details

#initialize(image, options) ⇒ Pusher

Returns a new instance of Pusher.



9
10
11
12
13
14
# 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

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



36
37
38
# File 'lib/ufo/docker/pusher.rb', line 36

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

#image_nameObject

full_image - does not include the tag



47
48
49
# File 'lib/ufo/docker/pusher.rb', line 47

def image_name
  settings[:image]
end

#pushObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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_tokenObject



40
41
42
43
44
# 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