From 8cffe586ed080f5abfa1dfdfeda8aa9f3d2b7078 Mon Sep 17 00:00:00 2001 From: Tianhao Geng Date: Wed, 27 Sep 2023 21:16:29 +0000 Subject: [PATCH] testsys: add image_id label at metal cluster crd --- tools/testsys/src/metal_k8s.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/testsys/src/metal_k8s.rs b/tools/testsys/src/metal_k8s.rs index 1cf48d36e..0b72200d1 100644 --- a/tools/testsys/src/metal_k8s.rs +++ b/tools/testsys/src/metal_k8s.rs @@ -66,11 +66,24 @@ impl CrdCreator for MetalK8sCreator { })?, )?; + let kube_image_id = cluster_input + .image_id + .to_string() + .replace(['.', '/'], "_") + .chars() + .rev() + .take(60) + .collect::() + .chars() + .rev() + .collect(); + let labels = cluster_input.crd_input.labels(btreemap! { "testsys/type".to_string() => "cluster".to_string(), "testsys/cluster".to_string() => cluster_name.clone(), "testsys/controlPlaneEndpoint".to_string() => control_plane_endpoint_ip, - "testsys/k8sVersion".to_string() => k8s_version + "testsys/k8sVersion".to_string() => k8s_version, + "testsys/imageId".to_string() => kube_image_id, }); // Check if the cluster already has a CRD @@ -83,6 +96,7 @@ impl CrdCreator for MetalK8sCreator { "testsys/type", "testsys/controlPlaneEndpoint", "testsys/k8sVersion", + "testsys/imageId", ], ) .await? @@ -152,7 +166,7 @@ impl CrdCreator for MetalK8sCreator { .to_owned(), ) .privileged(true) - .build(cluster_name) + .build(cluster_name + "-" + &cluster_input.crd_input.test_type.to_string()) .context(error::BuildSnafu { what: "metal K8s cluster CRD", })?;