From bfc713ac5623887b438240d60d84eaf175b2315a Mon Sep 17 00:00:00 2001 From: Robby Callicotte Date: Sat, 9 Feb 2019 12:57:34 -0600 Subject: [PATCH 1/3] Changed docker.login function to use config.option instead of only consulting Pillar. Data structure is required to only pass `docker-registries` key. Fixes #51531. --- salt/modules/dockermod.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/salt/modules/dockermod.py b/salt/modules/dockermod.py index 5d02426b1a84..0cfd1d3bfa31 100644 --- a/salt/modules/dockermod.py +++ b/salt/modules/dockermod.py @@ -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 @@ -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 @@ -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: From 8311691d7e029bd498065c475c17be50325839a8 Mon Sep 17 00:00:00 2001 From: Robby Callicotte Date: Sat, 9 Feb 2019 13:06:14 -0600 Subject: [PATCH 2/3] Changed docker.login function to use config.option instead of only consulting Pillar. Data structure is required to only pass `docker-registries` key. Corrected typo in config.option call. Fixes #51531. --- salt/modules/dockermod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/dockermod.py b/salt/modules/dockermod.py index 0cfd1d3bfa31..7ce4250403e2 100644 --- a/salt/modules/dockermod.py +++ b/salt/modules/dockermod.py @@ -1387,7 +1387,7 @@ 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 = __salt__['config.option]('docker-registries', {}) + registry_auth = __salt__['config.option']('docker-registries', {}) ret = {'retcode': 0} errors = ret.setdefault('Errors', []) if not isinstance(registry_auth, dict): From fc3c48a7bd0f5578a7ef645b110e7a1f297d4c8c Mon Sep 17 00:00:00 2001 From: Robby Callicotte Date: Sat, 9 Feb 2019 13:23:05 -0600 Subject: [PATCH 3/3] Changed docker.login function to use config.option instead of only consulting Pillar. Data structure is required to only pass `docker-registries` key. Corrected typo in config.option call. Corrected grammar in docstring. Fixes #51531. --- salt/modules/dockermod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/dockermod.py b/salt/modules/dockermod.py index 7ce4250403e2..9159e2770ddf 100644 --- a/salt/modules/dockermod.py +++ b/salt/modules/dockermod.py @@ -1361,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.