add option to force a reauth for a docker registry (#36893)

* add option to force a reauth for a docker registry

Fixes #32829. Adds ability to specify reauth in the docker-registry pillar data structure to specify the reauth kwarg to docker-py login call. If not specified it defaults to old behaviour of False

* added documentation for the new reuth option in docker registry configuration

also fixed a typo in the new code where I used cred instead of creds
This commit is contained in:
Tyler Hunt 2016-10-13 08:52:32 -06:00 committed by Nicole Thomas
parent 304516420c
commit 39cd3ca552

View File

@ -60,6 +60,7 @@ The configuration schema is as follows:
email: <email_address> email: <email_address>
password: <password> password: <password>
username: <username> username: <username>
reauth: <boolean>
For example: For example:
@ -71,6 +72,18 @@ For example:
password: s3cr3t password: s3cr3t
username: foo username: foo
Reauth is an optional parameter that forces the docker login to reauthorize using
the credentials passed in the pillar data. Defaults to false. For example:
.. code-block:: yaml
docker-registries:
https://index.docker.io/v1/:
email: foo@foo.com
password: s3cr3t
username: foo
reauth: True
Mulitiple registries can be configured. This can be done in one of two ways. Mulitiple registries can be configured. This can be done in one of two ways.
The first way is to configure each registry under the ``docker-registries`` The first way is to configure each registry under the ``docker-registries``
pillar key. pillar key.
@ -1031,7 +1044,8 @@ def _image_wrapper(attr, *args, **kwargs):
creds['username'], creds['username'],
password=creds['password'], password=creds['password'],
email=creds.get('email'), email=creds.get('email'),
registry=registry) registry=registry,
reauth=creds.get('reauth', False))
except KeyError: except KeyError:
raise SaltInvocationError( raise SaltInvocationError(
err.format('Incomplete', ' for registry {0}'.format(registry)) err.format('Incomplete', ' for registry {0}'.format(registry))