class Kubes::Auth::Ecr

Public Instance Methods

fetch_auth_token() click to toggle source
# File lib/kubes/auth/ecr.rb, line 37
def fetch_auth_token
  ecr.get_authorization_token.authorization_data.first.authorization_token
end
run() click to toggle source
# File lib/kubes/auth/ecr.rb, line 20
def run
  auth_token = fetch_auth_token
  if File.exist?(docker_config)
    data = JSON.load(IO.read(docker_config))
    data["auths"][@repo_domain] = {auth: auth_token}
  else
    data = {"auths" => {@repo_domain => {auth: auth_token}}}
  end

  # Handle legacy docker clients that still have old format with https://
  legacy_entry = "https://#{@repo_domain}"
  data["auths"][legacy_entry] = {auth: auth_token}

  ensure_dotdocker_exists
  IO.write(docker_config, JSON.pretty_generate(data))
end