Module: Tagfish::DockerHttpAuth
- Defined in:
- lib/tagfish/docker_http_auth.rb
Defined Under Namespace
Classes: Credentials
Class Method Summary collapse
Class Method Details
.for_registry(registry) ⇒ Object
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 self.for_registry(registry) file_path = '~/.docker/config.json' begin config = File.open(File.(file_path), 'r') rescue Exception => e abort("Tried to get username/password but the file #{file_path} does not exist") end json_config = JSON.parse(config.read()) config.close() if json_config['auths'].length == 0 Credentials.new(nil, nil) else b64_auth = json_config['auths'][registry]['auth'] auth = Base64.decode64(b64_auth) Credentials.new(*auth.split(':')) end end |