Module: Docker::Template::Auth

Defined in:
lib/docker/template/auth.rb

Class Method Summary collapse

Class Method Details

.auth!Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/docker/template/auth.rb', line 6

def auth!
  return unless  = credentials
  ["auths"].each do |server, auth|
    username, password = Base64.decode64(auth["auth"]).split(":", 2)
    Docker.authenticate!({
      "username" => username,
      "serveraddress" => server,
      "email" => auth["email"],
      "password" => password
    })
  end
end

.credentialsObject



19
20
21
22
# File 'lib/docker/template/auth.rb', line 19

def credentials
  path = Pathname.new("~/.docker/config.json").expand_path
  JSON.parse(path.read) if path.exist?
end