33from sh import minder
44
55from robot .api import logger
6- from resources .constants import MINDER_CONFIG , MINDER_OFFLINE_TOKEN_PATH , MINDER_API_ENDPOINT
6+ from resources .constants import (
7+ MINDER_CONFIG ,
8+ MINDER_OFFLINE_TOKEN_PATH ,
9+ MINDER_API_ENDPOINT ,
10+ )
711
812
913def _get_url_from_config (server_type ):
1014 """Helper function to read config and return URL for a given server type."""
1115 minder_config_path = os .getenv (MINDER_CONFIG )
1216 if not minder_config_path :
13- raise Exception (f' { MINDER_CONFIG } environment variable is not set' )
17+ raise Exception (f" { MINDER_CONFIG } environment variable is not set" )
1418
15- with open (minder_config_path , 'r' ) as file :
19+ with open (minder_config_path , "r" ) as file :
1620 config = yaml .safe_load (file )
1721
18- host = config [f' { server_type } _server' ].get (' host' , None )
22+ host = config [f" { server_type } _server" ].get (" host" , None )
1923 if not host :
20- raise Exception (f"Missing expected configuration key: { server_type } _server.host" )
21- port = config [f'{ server_type } _server' ].get ('port' , None )
24+ raise Exception (
25+ f"Missing expected configuration key: { server_type } _server.host"
26+ )
27+ port = config [f"{ server_type } _server" ].get ("port" , None )
2228
23- if server_type == ' http' :
24- protocol = ' http://'
29+ if server_type == " http" :
30+ protocol = " http://"
2531 if port == 443 :
26- protocol = ' https://'
32+ protocol = " https://"
2733 if port is None :
2834 return f"{ protocol } { host } "
2935 return f"{ protocol } { host } :{ port } "
@@ -36,26 +42,26 @@ def _get_url_from_config(server_type):
3642def get_rest_url_from_config ():
3743 """Reads the MINDER_CONFIG environment variable, loads the YAML config, and returns the REST BASE_URL."""
3844 try :
39- return _get_url_from_config (' http' )
45+ return _get_url_from_config (" http" )
4046 except FileNotFoundError :
41- return f' https://{ MINDER_API_ENDPOINT } '
47+ return f" https://{ MINDER_API_ENDPOINT } "
4248
4349
4450def get_grpc_url_from_config ():
4551 """Reads the MINDER_CONFIG environment variable, loads the YAML config, and returns the gRPC BASE_URL."""
4652 try :
47- return _get_url_from_config (' grpc' )
53+ return _get_url_from_config (" grpc" )
4854 except FileNotFoundError :
4955 return MINDER_API_ENDPOINT
5056
5157
5258def log_into_minder ():
53- logger .info (' Logging into minder' )
59+ logger .info (" Logging into minder" )
5460 if MINDER_OFFLINE_TOKEN_PATH not in os .environ :
55- raise Exception (f' { MINDER_OFFLINE_TOKEN_PATH } env variable is not set' )
61+ raise Exception (f" { MINDER_OFFLINE_TOKEN_PATH } env variable is not set" )
5662 tokenpath = os .environ [MINDER_OFFLINE_TOKEN_PATH ]
5763 if not tokenpath :
5864 raise Exception ("MINDER_OFFLINE_TOKEN_PATH env variable is empty" )
5965
60- logger .info (minder .auth (' offline-token' , ' use' , ' --file' , tokenpath ))
66+ logger .info (minder .auth (" offline-token" , " use" , " --file" , tokenpath ))
6167 return True
0 commit comments