Class: Ufo::Docker::Pusher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Pretty

#pretty_home, #pretty_path, #pretty_time

Methods included from Utils::Logging

#logger

Methods included from Utils::Execute

#execute, #user_params

Constructor Details

#initialize(image, options) ⇒ Pusher

Returns a new instance of Pusher.



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

def initialize(image, options)
  @options = options
  # docker_image ultimately uses @options, so @last_image_name assignment
  # line must be defined after setting @options.
  @last_image_name = image || docker_image
end

Instance Attribute Details

#last_image_nameObject (readonly)

Returns the value of attribute last_image_name.



6
7
8
# File 'lib/ufo/docker/pusher.rb', line 6

def last_image_name
  @last_image_name
end

Instance Method Details

#builderObject



29
30
31
# File 'lib/ufo/docker/pusher.rb', line 29

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

#pushObject



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

def push
  update_auth_token
  start_time = Time.now
  logger.info "Pushing Docker Image"
  command = "docker push #{last_image_name}"
  log = ".ufo/log/docker.log" if @options[:quiet]
  success = execute(command, log: log)
  unless success
    logger.info "ERROR: The docker image fail to push.".color(:red)
    exit 1
  end
  took = Time.now - start_time
  logger.info "Took #{pretty_time(took)}"
end

#update_auth_tokenObject



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

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