Method: Ecr::Auth#update

Defined in:
lib/ufo/ecr/auth.rb

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ufo/ecr/auth.rb', line 25

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
  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