22import json as json
33from collections import namedtuple
44from logging import warning
5- from typing import Optional
5+ from typing import Any , Optional
66
77DockerAuthInfo = namedtuple ("DockerAuthInfo" , ["registry" , "username" , "password" ])
88
1212}
1313
1414
15- def process_docker_auth_config_encoded (auth_config_dict : dict ) -> list [DockerAuthInfo ]:
15+ def process_docker_auth_config_encoded (auth_config_dict : dict [ str , dict [ str , dict [ str , Any ]]] ) -> list [DockerAuthInfo ]:
1616 """
1717 Process the auths config.
1818
@@ -30,16 +30,19 @@ def process_docker_auth_config_encoded(auth_config_dict: dict) -> list[DockerAut
3030 auth_info : list [DockerAuthInfo ] = []
3131
3232 auths = auth_config_dict .get ("auths" )
33+ if not auths :
34+ raise KeyError ("No auths found in the docker auth config" )
35+
3336 for registry , auth in auths .items ():
34- auth_str = auth .get ("auth" )
37+ auth_str = str ( auth .get ("auth" ) )
3538 auth_str = base64 .b64decode (auth_str ).decode ("utf-8" )
3639 username , password = auth_str .split (":" )
3740 auth_info .append (DockerAuthInfo (registry , username , password ))
3841
3942 return auth_info
4043
4144
42- def process_docker_auth_config_cred_helpers (auth_config_dict : dict ) -> None :
45+ def process_docker_auth_config_cred_helpers (auth_config_dict : dict [ str , Any ] ) -> None :
4346 """
4447 Process the credHelpers config.
4548
@@ -56,7 +59,7 @@ def process_docker_auth_config_cred_helpers(auth_config_dict: dict) -> None:
5659 warning (_AUTH_WARNINGS .pop ("credHelpers" ))
5760
5861
59- def process_docker_auth_config_store (auth_config_dict : dict ) -> None :
62+ def process_docker_auth_config_store (auth_config_dict : dict [ str , Any ] ) -> None :
6063 """
6164 Process the credsStore config.
6265
@@ -74,7 +77,7 @@ def process_docker_auth_config_store(auth_config_dict: dict) -> None:
7477def parse_docker_auth_config (auth_config : str ) -> Optional [list [DockerAuthInfo ]]:
7578 """Parse the docker auth config from a string and handle the different formats."""
7679 try :
77- auth_config_dict : dict = json .loads (auth_config )
80+ auth_config_dict : dict [ str , Any ] = json .loads (auth_config )
7881 if "credHelpers" in auth_config :
7982 process_docker_auth_config_cred_helpers (auth_config_dict )
8083 if "credsStore" in auth_config :
0 commit comments