@@ -309,7 +309,11 @@ def get_default_kueue_name(namespace: str):
309
309
310
310
311
311
def write_components (
312
- user_yaml : dict , output_file_name : str , namespace : str , local_queue : Optional [str ]
312
+ user_yaml : dict ,
313
+ output_file_name : str ,
314
+ namespace : str ,
315
+ local_queue : Optional [str ],
316
+ user_labels : dict ,
313
317
):
314
318
# Create the directory if it doesn't exist
315
319
directory_path = os .path .dirname (output_file_name )
@@ -331,6 +335,8 @@ def write_components(
331
335
]
332
336
labels = component ["generictemplate" ]["metadata" ]["labels" ]
333
337
labels .update ({"kueue.x-k8s.io/queue-name" : lq_name })
338
+ for key in user_labels :
339
+ labels .update ({key : user_labels [key ]})
334
340
outfile .write ("---\n " )
335
341
yaml .dump (
336
342
component ["generictemplate" ], outfile , default_flow_style = False
@@ -339,7 +345,11 @@ def write_components(
339
345
340
346
341
347
def load_components (
342
- user_yaml : dict , name : str , namespace : str , local_queue : Optional [str ]
348
+ user_yaml : dict ,
349
+ name : str ,
350
+ namespace : str ,
351
+ local_queue : Optional [str ],
352
+ user_labels : dict ,
343
353
):
344
354
component_list = []
345
355
components = user_yaml .get ("spec" , "resources" )["resources" ].get ("GenericItems" )
@@ -355,6 +365,8 @@ def load_components(
355
365
]
356
366
labels = component ["generictemplate" ]["metadata" ]["labels" ]
357
367
labels .update ({"kueue.x-k8s.io/queue-name" : lq_name })
368
+ for key in user_labels :
369
+ labels .update ({key : user_labels [key ]})
358
370
component_list .append (component ["generictemplate" ])
359
371
360
372
resources = "---\n " + "---\n " .join (
@@ -395,6 +407,7 @@ def generate_appwrapper(
395
407
write_to_file : bool ,
396
408
verify_tls : bool ,
397
409
local_queue : Optional [str ],
410
+ user_labels ,
398
411
):
399
412
user_yaml = read_template (template )
400
413
appwrapper_name , cluster_name = gen_names (name )
@@ -446,11 +459,13 @@ def generate_appwrapper(
446
459
if mcad :
447
460
write_user_appwrapper (user_yaml , outfile )
448
461
else :
449
- write_components (user_yaml , outfile , namespace , local_queue )
462
+ write_components (user_yaml , outfile , namespace , local_queue , user_labels )
450
463
return outfile
451
464
else :
452
465
if mcad :
453
466
user_yaml = load_appwrapper (user_yaml , name )
454
467
else :
455
- user_yaml = load_components (user_yaml , name , namespace , local_queue )
468
+ user_yaml = load_components (
469
+ user_yaml , name , namespace , local_queue , user_labels
470
+ )
456
471
return user_yaml
0 commit comments