@@ -12,6 +12,7 @@ import (
1212 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1313 addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
1414 "sigs.k8s.io/cluster-api/test/e2e"
15+ "sigs.k8s.io/cluster-api/test/framework"
1516 "sigs.k8s.io/controller-runtime/pkg/client"
1617
1718 . "github.com/onsi/gomega"
@@ -77,7 +78,7 @@ func FixupNamespace(e2eCtx *E2EContext, namespace string, enableCredentials bool
7778}
7879
7980// FixupWorkloadCluster patches the workload cluster object to install CNI.
80- func FixupWorkloadCluster (e2eCtx * E2EContext , name string , namespace string , cni bool ) {
81+ func FixupWorkloadCluster (e2eCtx * E2EContext , name string , namespace string ) {
8182 clusterClient := e2eCtx .Environment .BootstrapClusterProxy .GetClient ()
8283
8384 clusterName := types.NamespacedName {Name : name , Namespace : namespace }
@@ -86,16 +87,12 @@ func FixupWorkloadCluster(e2eCtx *E2EContext, name string, namespace string, cni
8687 e2e .Byf ("Fetch workload cluster %v" , clusterName )
8788 Expect (clusterClient .Get (context .TODO (), clusterName , cluster )).To (Succeed (), "Failed to retrieve workload cluster" )
8889
89- // Label cluster to match ClusterResourceSet that deploys the CNI
90- if cni {
91- e2e .Byf ("Label workload cluster %v with cni=cni-resources" , clusterName )
92-
93- if cluster .Labels == nil {
94- cluster .Labels = make (map [string ]string , 1 )
95- }
96- cluster .Labels ["cni" ] = "cni-resources"
97- }
98-
9990 e2e .Byf ("Patch workload cluster %v" , clusterName )
100- Expect (clusterClient .Update (context .TODO (), cluster )).To (Succeed (), "Failed to patch workload cluster with necessary labels and configs" )
91+ framework .PatchClusterLabel (context .TODO (), framework.PatchClusterLabelInput {
92+ ClusterProxy : e2eCtx .Environment .BootstrapClusterProxy ,
93+ Cluster : cluster ,
94+ Labels : map [string ]string {
95+ "cni" : "cni-resources" ,
96+ },
97+ })
10198}
0 commit comments