Class: Tagfish::DockerHttpAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/tagfish/docker_http_auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry) ⇒ DockerHttpAuth



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tagfish/docker_http_auth.rb', line 10

def initialize(registry)
   file_path = '~/.docker/config.json'

   begin
     config = File.open(File.expand_path(file_path), 'r')
   rescue Exception => e
     abort("Tried to get a SLiP but the file #{file_path} does not exist")
   end

   json_config = JSON.parse(config.read())
   config.close()
   if json_config['auths'].length == 0
     @username, @password = nil, nil 
   else
     b64_auth = json_config['auths'][registry]['auth']
     auth = Base64.decode64(b64_auth)
     @username, @password = auth.split(':')
   end
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/tagfish/docker_http_auth.rb', line 8

def password
  @password
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/tagfish/docker_http_auth.rb', line 7

def username
  @username
end