Class: Ufo::Docker::Pusher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hooks::Concern

#run_hooks

Methods included from Concerns

#build, #deploy, #info, #ps

Methods included from Concerns::Names

#names

Constructor Details

#initialize(image, options) ⇒ Pusher

Returns a new instance of Pusher.



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

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.



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

def last_image_name
  @last_image_name
end

Instance Method Details

#builderObject



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

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

#pushObject



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

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 = nil
  run_hooks(name: "push", file: "docker.rb") do
    success = execute(command, log: log)
  end
  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



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

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