33from typing import Any , Dict , Optional
44
55from podman .api .client import APIClient
6+ from podman import api
67
78logger = logging .getLogger ("podman.system" )
89
@@ -40,8 +41,8 @@ def login(
4041 password : Optional [str ] = None ,
4142 email : Optional [str ] = None ,
4243 registry : Optional [str ] = None ,
43- reauth : bool = False ,
44- dockercfg_path : Optional [str ] = None ,
44+ reauth : Optional [ bool ] = False , # pylint: disable=unused-argument
45+ dockercfg_path : Optional [str ] = None , # pylint: disable=unused-argument
4546 ) -> Dict [str , Any ]:
4647 """Log into Podman service.
4748
@@ -50,12 +51,27 @@ def login(
5051 password: Registry plaintext password
5152 email: Registry account email address
5253 registry: URL for registry access. For example,
54+ reauth: Ignored: If True, refresh existing authentication. Default: False
55+ dockercfg_path: Ignored: Path to custom configuration file.
5356 https://quay.io/v2
54- reauth: If True, refresh existing authentication. Default: False
55- dockercfg_path: Path to custom configuration file.
56- Default: $HOME/.config/containers/config.json
5757 """
5858
59+ payload = {
60+ "username" : username ,
61+ "password" : password ,
62+ "email" : email ,
63+ "serveraddress" : registry ,
64+ }
65+ payload = api .prepare_body (payload )
66+ response = self .client .post (
67+ path = "/auth" ,
68+ headers = {"Content-type" : "application/json" },
69+ data = payload ,
70+ compatible = True ,
71+ )
72+ response .raise_for_status ()
73+ return response .json ()
74+
5975 def ping (self ) -> bool :
6076 """Returns True if service responded with OK."""
6177 response = self .client .head ("/_ping" )
0 commit comments