Skip to content
This repository was archived by the owner on Jan 20, 2020. It is now read-only.

Commit 4325c7c

Browse files
committed
Merge branch 'staging'
2 parents 56c8064 + 06988c3 commit 4325c7c

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM python:2.7.11-alpine
22

3+
RUN apk update && apk add ca-certificates
4+
35
ADD . /sdk
46
WORKDIR sdk
57
RUN python setup.py install

dockercloud/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from dockercloud.api.events import Events
2626
from dockercloud.api.nodeaz import AZ
2727

28-
__version__ = '1.0.7'
28+
__version__ = '1.0.8'
2929

3030
dockercloud_auth = os.environ.get('DOCKERCLOUD_AUTH')
3131
basic_auth = auth.load_from_file("~/.docker/config.json")

dockercloud/api/auth.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import base64
44
import json
55
import os
6+
import subprocess
67

78
from requests.auth import HTTPBasicAuth
89

910
import dockercloud
1011
from .http import send_request
1112

13+
HUB_INDEX = "https://index.docker.io/v1/"
1214

1315
def authenticate(username, password):
1416
verify_credential(username, password)
@@ -43,11 +45,29 @@ def load_from_file(f="~/.docker/config.json"):
4345
try:
4446
with open(os.path.expanduser(f)) as config_file:
4547
data = json.load(config_file)
46-
47-
return data.get("auths", {}).get("https://index.docker.io/v1/", {}).get("auth", None)
48-
except Exception:
48+
except:
4949
return None
5050

51+
creds_store = data.get("credsStore", None)
52+
if creds_store:
53+
try:
54+
cmd = "docker-credential-" + creds_store
55+
p = subprocess.Popen([cmd, 'get'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
56+
out = p.communicate(input=HUB_INDEX)[0]
57+
except:
58+
raise dockercloud.AuthError('error getting credentials - err: exec: "%s": executable file not found in $PATH, out: ``' % cmd)
59+
60+
try:
61+
credential = json.loads(out)
62+
username = credential.get("Username")
63+
password = credential.get("Secret")
64+
return base64.b64encode("%s:%s" % (username, password))
65+
except:
66+
return None
67+
68+
else:
69+
return data.get("auths", {}).get(HUB_INDEX, {}).get("auth", None)
70+
5171

5272
def get_auth_header():
5373
try:

0 commit comments

Comments
 (0)