class Ufo::Ecr::Auth
Public Class Methods
new(full_image_name)
click to toggle source
# File lib/ufo/ecr/auth.rb, line 22 def initialize(full_image_name) @full_image_name = full_image_name @repo_domain = "#{full_image_name.split('/').first}" end
Public Instance Methods
ecr_image?()
click to toggle source
# File lib/ufo/ecr/auth.rb, line 43 def ecr_image? !!(@full_image_name =~ /\.amazonaws\.com/) end
fetch_auth_token()
click to toggle source
# File lib/ufo/ecr/auth.rb, line 47 def fetch_auth_token ecr.get_authorization_token.authorization_data.first.authorization_token end
update()
click to toggle source
# File lib/ufo/ecr/auth.rb, line 27 def update # wont update auth token unless the image being pushed in the ECR image format return unless ecr_image? auth_token = fetch_auth_token username, password = Base64.decode64(auth_token).split(':') command = "docker login -u #{username} --password-stdin #{@repo_domain}" puts "=> #{command}".color(:green) *, status = Open3.capture3(command, stdin_data: password) unless status.success? puts "ERROR: The docker failed to login.".color(:red) exit 1 end end