mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 20:08:41 +00:00
Work around bug in Docker 28.3.3 that prevents pushing to registry without authentication. (#1110)
This commit is contained in:
parent
cfd59ac9e5
commit
e1920d1cc7
3
changelogs/fragments/1110-push-fix.yml
Normal file
3
changelogs/fragments/1110-push-fix.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "docker_image, docker_image_push - work around a bug in Docker 28.3.3 that prevents pushing without authentication to a registry
|
||||||
|
(https://github.com/ansible-collections/community.docker/pull/1110)."
|
||||||
@ -363,6 +363,7 @@ stdout:
|
|||||||
version_added: 1.0.0
|
version_added: 1.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
import errno
|
import errno
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@ -716,8 +717,11 @@ class ImageManager(DockerBaseClass):
|
|||||||
push_registry, dummy = resolve_repository_name(push_repository)
|
push_registry, dummy = resolve_repository_name(push_repository)
|
||||||
headers = {}
|
headers = {}
|
||||||
header = get_config_header(self.client, push_registry)
|
header = get_config_header(self.client, push_registry)
|
||||||
if header:
|
if not header:
|
||||||
headers['X-Registry-Auth'] = header
|
# For some reason, from Docker 28.3.3 on not specifying X-Registry-Auth seems to be invalid.
|
||||||
|
# See https://github.com/moby/moby/issues/50614.
|
||||||
|
header = base64.urlsafe_b64encode(b"{}")
|
||||||
|
headers['X-Registry-Auth'] = header
|
||||||
response = self.client._post_json(
|
response = self.client._post_json(
|
||||||
self.client._url("/images/{0}/push", push_repository),
|
self.client._url("/images/{0}/push", push_repository),
|
||||||
data=None,
|
data=None,
|
||||||
|
|||||||
@ -72,6 +72,7 @@ image:
|
|||||||
sample: {}
|
sample: {}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
@ -142,8 +143,11 @@ class ImagePusher(DockerBaseClass):
|
|||||||
|
|
||||||
headers = {}
|
headers = {}
|
||||||
header = get_config_header(self.client, push_registry)
|
header = get_config_header(self.client, push_registry)
|
||||||
if header:
|
if not header:
|
||||||
headers['X-Registry-Auth'] = header
|
# For some reason, from Docker 28.3.3 on not specifying X-Registry-Auth seems to be invalid.
|
||||||
|
# See https://github.com/moby/moby/issues/50614.
|
||||||
|
header = base64.urlsafe_b64encode(b"{}")
|
||||||
|
headers['X-Registry-Auth'] = header
|
||||||
response = self.client._post_json(
|
response = self.client._post_json(
|
||||||
self.client._url("/images/{0}/push", self.name),
|
self.client._url("/images/{0}/push", self.name),
|
||||||
data=None,
|
data=None,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user