Skip to content

Commit e53a67a

Browse files
committed
Set X-Registry-Auth header on manifest push and bump to new API
Signed-off-by: dklimpel <[email protected]>
1 parent a75e8c2 commit e53a67a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

podman/domain/manifests.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any, Optional, Union
77

88
from podman import api
9+
from podman.api.http_utils import encode_auth_header
910
from podman.domain.images import Image
1011
from podman.domain.manager import Manager, PodmanResource
1112
from podman.errors import ImageNotFound
@@ -97,22 +98,40 @@ def push(
9798
self,
9899
destination: str,
99100
all: Optional[bool] = None, # pylint: disable=redefined-builtin
101+
**kwargs,
100102
) -> None:
101103
"""Push a manifest list or image index to a registry.
102104
103105
Args:
104106
destination: Target for push.
105107
all: Push all images.
106108
109+
Keyword Args:
110+
auth_config (Mapping[str, str]: Override configured credentials. Must include
111+
username and password keys.
112+
107113
Raises:
108114
NotFound: when the Manifest could not be found
109115
APIError: when service reports an error
110116
"""
117+
auth_config: Optional[dict[str, str]] = kwargs.get("auth_config")
118+
119+
headers = {
120+
# A base64url-encoded auth configuration
121+
"X-Registry-Auth": encode_auth_header(auth_config) if auth_config else ""
122+
}
123+
111124
params = {
112125
"all": all,
113126
"destination": destination,
114127
}
115-
response = self.client.post(f"/manifests/{self.quoted_name}/push", params=params)
128+
129+
destination_quoted = urllib.parse.quote_plus(destination)
130+
response = self.client.post(
131+
f"/manifests/{self.quoted_name}/registry/{destination_quoted}",
132+
params=params,
133+
headers=headers,
134+
)
116135
response.raise_for_status()
117136

118137
def remove(self, digest: str) -> None:

0 commit comments

Comments
 (0)