Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker login 51531 #51571

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions salt/modules/dockermod.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@
``https://index.docker.io/v1/``).

More than one registry can be configured. Salt will look for Docker credentials
in the ``docker-registries`` Pillar key, as well as any key ending in
``-docker-registries``. For example:
in the ``docker-registries`` key. For example:

.. code-block:: yaml

Expand All @@ -86,12 +85,10 @@
username: foo
password: s3cr3t

foo-docker-registries:
https://index.foo.io/v1/:
username: foo
password: s3cr3t

bar-docker-registries:
https://index.bar.io/v1/:
username: foo
password: s3cr3t
Expand Down Expand Up @@ -1364,7 +1361,7 @@ def login(*registries):
repositories. See the documentation at the top of this page to configure
authentication credentials.

Multiple registry URLs (matching those configured in Pillar) can be passed,
Multiple registry URLs (matching those configured in master, minion, or pillar) can be passed,
and Salt will attempt to login to *just* those registries. If no registry
URLs are provided, Salt will attempt to login to *all* configured
registries.
Expand All @@ -1390,24 +1387,13 @@ def login(*registries):
# NOTE: This function uses the "docker login" CLI command so that login
# information is added to the config.json, since docker-py isn't designed
# to do so.
registry_auth = __pillar__.get('docker-registries', {})
registry_auth = __salt__['config.option']('docker-registries', {})
ret = {'retcode': 0}
errors = ret.setdefault('Errors', [])
if not isinstance(registry_auth, dict):
errors.append(
'\'docker-registries\' Pillar value must be a dictionary')
'\'docker-registries\' Config value must be a dictionary')
registry_auth = {}
for key, data in six.iteritems(__pillar__):
try:
if key.endswith('-docker-registries'):
try:
registry_auth.update(data)
except TypeError:
errors.append(
'\'{0}\' Pillar value must be a dictionary'.format(key)
)
except AttributeError:
pass

# If no registries passed, we will auth to all of them
if not registries:
Expand Down