1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

docker_swarm_service: Support resolving images from private registries (#53997)

* Override inspect_distribution to fetch digest

* Formatting fix

* Use single quote strings
This commit is contained in:
Hannes Ljungberg 2019-03-19 06:39:17 +01:00 committed by ansibot
parent 38346d0337
commit 4ed3735cda

View file

@ -689,6 +689,21 @@ class AnsibleDockerClient(Client):
elif isinstance(result, string_types) and result:
self.module.warn('Docker warning: {0}'.format(result))
def inspect_distribution(self, image):
'''
Get image digest by directly calling the Docker API when running Docker SDK < 4.0.0
since prior versions did not support accessing private repositories.
'''
if self.docker_py_version < LooseVersion('4.0.0'):
registry = auth.resolve_repository_name(image)[0]
header = auth.get_config_header(self, registry)
if header:
return self._result(self._get(
self._url('/distribution/{0}/json', image),
headers={'X-Registry-Auth': header}
), json=True)
return super(AnsibleDockerClient, self).inspect_distribution(image)
def compare_dict_allow_more_present(av, bv):
'''