class RakeDocker::Authentication::ECR

Public Class Methods

new(&block) click to toggle source
# File lib/rake_docker/authentication/ecr.rb, line 7
def initialize &block
  @config = OpenStruct.new(
      region: nil,
      registry_id: nil)
  block.call(@config)

  @ecr_client = Aws::ECR::Client.new(region: @config.region)
end

Public Instance Methods

arity() click to toggle source
# File lib/rake_docker/authentication/ecr.rb, line 16
def arity
  0
end
call() click to toggle source
# File lib/rake_docker/authentication/ecr.rb, line 20
def call
  registry_id = @config.registry_id.respond_to?(:call) ?
      @config.registry_id.call :
      @config.registry_id

  token_response = @ecr_client.get_authorization_token(
      registry_ids: [registry_id])
  token_data = token_response.authorization_data[0]
  proxy_endpoint = token_data.proxy_endpoint
  email = 'none'
  username, password =
      Base64.decode64(token_data.authorization_token).split(':')

  {
      username: username, password: password, email: email,
      serveraddress: proxy_endpoint
  }
end