@@ -11,7 +11,7 @@ if str(local("command -v " + kubectl_cmd + " || true", quiet = True)) == "":
11
11
load ("ext://uibutton" , "cmd_button" , "location" , "text_input" )
12
12
13
13
# set defaults
14
- version_settings (True , ">=0.22.2 " )
14
+ version_settings (True , ">=0.30.8 " )
15
15
16
16
settings = {
17
17
"enable_providers" : ["docker" ],
@@ -441,10 +441,6 @@ def cluster_templates():
441
441
substitutions ["CONTROL_PLANE_MACHINE_COUNT" ] = substitutions .get ("CONTROL_PLANE_MACHINE_COUNT" , "1" )
442
442
substitutions ["WORKER_MACHINE_COUNT" ] = substitutions .get ("WORKER_MACHINE_COUNT" , "3" )
443
443
444
- # Note: this is a workaround to pass env variables to cmd buttons while this is not supported natively like in local_resource
445
- for name , value in substitutions .items ():
446
- os .environ [name ] = value
447
-
448
444
template_dirs = settings .get ("template_dirs" , {
449
445
"docker" : ["./test/infrastructure/docker/templates" ],
450
446
})
@@ -488,6 +484,7 @@ def deploy_clusterclass(clusterclass_name, label, filename, substitutions):
488
484
cmd_button (
489
485
clusterclass_name + ":apply" ,
490
486
argv = ["bash" , "-c" , apply_clusterclass_cmd ],
487
+ env = dictonary_to_list_of_string (substitutions ),
491
488
resource = clusterclass_name ,
492
489
icon_name = "note_add" ,
493
490
text = "Apply `" + clusterclass_name + "` ClusterClass" ,
@@ -499,6 +496,7 @@ def deploy_clusterclass(clusterclass_name, label, filename, substitutions):
499
496
cmd_button (
500
497
clusterclass_name + ":delete" ,
501
498
argv = ["bash" , "-c" , delete_clusterclass_cmd ],
499
+ env = dictonary_to_list_of_string (substitutions ),
502
500
resource = clusterclass_name ,
503
501
icon_name = "delete_forever" ,
504
502
text = "Delete `" + clusterclass_name + "` ClusterClass" ,
@@ -523,6 +521,7 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
523
521
cmd_button (
524
522
template_name + ":apply" ,
525
523
argv = ["bash" , "-c" , apply_cluster_template_cmd ],
524
+ env = dictonary_to_list_of_string (substitutions ),
526
525
resource = template_name ,
527
526
icon_name = "add_box" ,
528
527
text = "Create `" + template_name + "` cluster" ,
@@ -537,6 +536,7 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
537
536
cmd_button (
538
537
template_name + ":delete" ,
539
538
argv = ["bash" , "-c" , delete_clusters_cmd ],
539
+ env = dictonary_to_list_of_string (substitutions ),
540
540
resource = template_name ,
541
541
icon_name = "delete_forever" ,
542
542
text = "Delete `" + template_name + "` clusters" ,
@@ -548,11 +548,19 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
548
548
cmd_button (
549
549
template_name + ":delete-all" ,
550
550
argv = ["bash" , "-c" , kubectl_cmd + " delete clusters --all --wait=false" ],
551
+ env = dictonary_to_list_of_string (substitutions ),
551
552
resource = template_name ,
552
553
icon_name = "delete_sweep" ,
553
554
text = "Delete all workload clusters" ,
554
555
)
555
556
557
+ # A function to convert dictonary to list of strings in a format of "name=value"
558
+ def dictonary_to_list_of_string (substitutions ):
559
+ substitutions_list = []
560
+ for name , value in substitutions .items ():
561
+ substitutions_list .append (name + "=" + value )
562
+ return substitutions_list
563
+
556
564
##############################
557
565
# Actual work happens here
558
566
##############################
0 commit comments