|
6 | 6 | from typing import Any, Optional, Union
|
7 | 7 |
|
8 | 8 | from podman import api
|
| 9 | +from podman.api.http_utils import encode_auth_header |
9 | 10 | from podman.domain.images import Image
|
10 | 11 | from podman.domain.manager import Manager, PodmanResource
|
11 | 12 | from podman.errors import ImageNotFound
|
@@ -97,22 +98,40 @@ def push(
|
97 | 98 | self,
|
98 | 99 | destination: str,
|
99 | 100 | all: Optional[bool] = None, # pylint: disable=redefined-builtin
|
| 101 | + **kwargs, |
100 | 102 | ) -> None:
|
101 | 103 | """Push a manifest list or image index to a registry.
|
102 | 104 |
|
103 | 105 | Args:
|
104 | 106 | destination: Target for push.
|
105 | 107 | all: Push all images.
|
106 | 108 |
|
| 109 | + Keyword Args: |
| 110 | + auth_config (Mapping[str, str]: Override configured credentials. Must include |
| 111 | + username and password keys. |
| 112 | +
|
107 | 113 | Raises:
|
108 | 114 | NotFound: when the Manifest could not be found
|
109 | 115 | APIError: when service reports an error
|
110 | 116 | """
|
| 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 | + |
111 | 124 | params = {
|
112 | 125 | "all": all,
|
113 | 126 | "destination": destination,
|
114 | 127 | }
|
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 | + ) |
116 | 135 | response.raise_for_status()
|
117 | 136 |
|
118 | 137 | def remove(self, digest: str) -> None:
|
|
0 commit comments