@@ -81,9 +81,7 @@ class UploadMockDataArgs(BaseModel):
8181)
8282jinja_env : contextvars .ContextVar [Environment ] = contextvars .ContextVar ("jinja_env" )
8383args : contextvars .ContextVar [UploadMockDataArgs ] = contextvars .ContextVar ("args" )
84- retries_remaining : contextvars .ContextVar [int ] = contextvars .ContextVar (
85- "retries_remaining"
86- )
84+ retries_remaining : contextvars .ContextVar [int ] = contextvars .ContextVar ("retries_remaining" )
8785
8886# NATS connection variables.
8987nats_client : None | NatsClient = None
@@ -180,9 +178,7 @@ def evaluate(self):
180178 # Attempt to evaluate expression against data context.
181179 value = jmespath .search (self .expression , data_context )
182180 if value is None :
183- raise AttributeError (
184- f"JMESPath expression '{ self .expression } ' not found in data"
185- )
181+ raise AttributeError (f"JMESPath expression '{ self .expression } ' not found in data" )
186182 return value
187183
188184
@@ -246,9 +242,7 @@ def replace_placeholder(match):
246242 # Attempt to evaluate expression against data context.
247243 value = jmespath .search (expression , data_context )
248244 if value is None :
249- raise AttributeError (
250- f"JMESPath expression '{ expression } ' not found in data"
251- )
245+ raise AttributeError (f"JMESPath expression '{ expression } ' not found in data" )
252246 return str (value )
253247
254248 # Find and replace all ${...} patterns with their evaluated values.
@@ -263,7 +257,7 @@ class JWTGenerator(yaml.YAMLObject):
263257 Arguments are passed as key=value pairs separated by commas.
264258
265259 Example:
266- !jwt aud=lfx-v2-project-service,principal=clients@ m2m_helper, \ \
260+ !jwt aud=lfx-v2-project-service,principal=m2m_helper@clients, \
267261268262 """
269263
@@ -331,7 +325,7 @@ def generate_jwt(self) -> str:
331325 payload = {
332326 "aud" : audience ,
333327 "iss" : "heimdall" ,
334- "sub" : principal .replace ("clients@ " , "" ), # Remove clients@ prefix .
328+ "sub" : principal .replace ("@clients " , "" ), # Remove @clients suffix .
335329 "principal" : principal ,
336330 "exp" : now_int + 300 , # 5 minutes expiry.
337331 "nbf" : now_int , # Valid from now.
@@ -349,9 +343,7 @@ def generate_jwt(self) -> str:
349343 )
350344 # Ensure we have an RSA private key for PS256 algorithm.
351345 if not isinstance (loaded_key , rsa .RSAPrivateKey ):
352- raise ValueError (
353- "JWT signing requires an RSA private key for PS256 algorithm"
354- )
346+ raise ValueError ("JWT signing requires an RSA private key for PS256 algorithm" )
355347 private_key = loaded_key
356348 except Exception as e :
357349 raise ValueError (f"Failed to load RSA private key: { e } " ) from e
@@ -385,9 +377,7 @@ def _get_key_id(self, cli_args) -> str:
385377 return _jwks_kid_cache
386378
387379 # Fetch from Heimdall JWKS endpoint.
388- jwks_url = (
389- "http://lfx-platform-heimdall.lfx.svc.cluster.local:4457/.well-known/jwks"
390- )
380+ jwks_url = "http://lfx-platform-heimdall.lfx.svc.cluster.local:4457/.well-known/jwks"
391381 try :
392382 response = requests .get (jwks_url , timeout = 10 )
393383 response .raise_for_status ()
@@ -542,9 +532,7 @@ def yaml_render(template_dir, yaml_file):
542532 env .globals ["fake" ] = fake
543533 env .globals ["timedelta" ] = datetime .timedelta
544534 env .globals ["now_z" ] = (
545- lambda : datetime .datetime .now (datetime .UTC )
546- .isoformat ("T" )
547- .replace ("+00:00" , "Z" )
535+ lambda : datetime .datetime .now (datetime .UTC ).isoformat ("T" ).replace ("+00:00" , "Z" )
548536 )
549537 env .globals ["slug_from_project_name" ] = slug_from_project_name
550538 # Store the environment in the context for use by the !include
@@ -755,9 +743,7 @@ def run_http_request_playbook(name: str, playbook: dict) -> None:
755743 except AttributeError as e :
756744 if cli_args .dry_run :
757745 if cli_args .force :
758- logger .error (
759- "Error processing playbook" , error = str (e ), playbook = name
760- )
746+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
761747 step_payload ["_response" ] = {}
762748 continue
763749 else :
@@ -766,9 +752,7 @@ def run_http_request_playbook(name: str, playbook: dict) -> None:
766752 if retries_remaining .get () > 0 :
767753 continue
768754 if cli_args .force :
769- logger .error (
770- "Error processing playbook" , error = str (e ), playbook = name
771- )
755+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
772756 continue
773757 raise
774758 if request_data is None and "raw" in step_payload :
@@ -808,9 +792,7 @@ def run_http_request_playbook(name: str, playbook: dict) -> None:
808792 step_payload ["_response" ] = r_dict
809793 except json .decoder .JSONDecodeError as e :
810794 if cli_args .force :
811- logger .error (
812- "Failed to parse response as JSON" , error = str (e ), playbook = name
813- )
795+ logger .error ("Failed to parse response as JSON" , error = str (e ), playbook = name )
814796 # Add a placeholder response to prevent re-running.
815797 step_payload ["_response" ] = {}
816798 continue
@@ -866,9 +848,7 @@ async def run_nats_publish_playbook(name: str, playbook: dict) -> None:
866848 except AttributeError as e :
867849 if cli_args .dry_run :
868850 if cli_args .force :
869- logger .error (
870- "Error processing playbook" , error = str (e ), playbook = name
871- )
851+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
872852 step_payload ["_response" ] = {}
873853 continue
874854 else :
@@ -877,9 +857,7 @@ async def run_nats_publish_playbook(name: str, playbook: dict) -> None:
877857 if retries_remaining .get () > 0 :
878858 continue
879859 if cli_args .force :
880- logger .error (
881- "Error processing playbook" , error = str (e ), playbook = name
882- )
860+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
883861 continue
884862 raise
885863 elif "raw" in step_payload :
@@ -978,9 +956,7 @@ async def run_nats_kv_put_playbook(name: str, playbook: dict) -> None:
978956 except AttributeError as e :
979957 if cli_args .dry_run :
980958 if cli_args .force :
981- logger .error (
982- "Error processing playbook" , error = str (e ), playbook = name
983- )
959+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
984960 step_payload ["_response" ] = {}
985961 continue
986962 else :
@@ -989,9 +965,7 @@ async def run_nats_kv_put_playbook(name: str, playbook: dict) -> None:
989965 if retries_remaining .get () > 0 :
990966 continue
991967 if cli_args .force :
992- logger .error (
993- "Error processing playbook" , error = str (e ), playbook = name
994- )
968+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
995969 continue
996970 raise
997971 elif "raw" in step_payload :
@@ -1076,9 +1050,7 @@ async def run_nats_request_playbook(name: str, playbook: dict) -> None:
10761050 except AttributeError as e :
10771051 if cli_args .dry_run :
10781052 if cli_args .force :
1079- logger .error (
1080- "Error processing playbook" , error = str (e ), playbook = name
1081- )
1053+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
10821054 step_payload ["_response" ] = {}
10831055 continue
10841056 else :
@@ -1087,9 +1059,7 @@ async def run_nats_request_playbook(name: str, playbook: dict) -> None:
10871059 if retries_remaining .get () > 0 :
10881060 continue
10891061 if cli_args .force :
1090- logger .error (
1091- "Error processing playbook" , error = str (e ), playbook = name
1092- )
1062+ logger .error ("Error processing playbook" , error = str (e ), playbook = name )
10931063 continue
10941064 raise
10951065 elif "raw" in step_payload :
@@ -1115,9 +1085,7 @@ async def run_nats_request_playbook(name: str, playbook: dict) -> None:
11151085 )
11161086
11171087 try :
1118- response = await nats_client .request (
1119- params .subject , data , timeout = params .timeout
1120- )
1088+ response = await nats_client .request (params .subject , data , timeout = params .timeout )
11211089 # Parse the response data and store it.
11221090 try :
11231091 response_data = json .loads (response .data .decode ())
0 commit comments