Skip to content

Commit d9f343d

Browse files
committed
VSphereClusterIdentity: ensure namespace in tests exists when not using the default
1 parent 220fd91 commit d9f343d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

controllers/vsphereclusteridentity_controller_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,28 @@ import (
2020
. "github.com/onsi/ginkgo/v2"
2121
. "github.com/onsi/gomega"
2222
corev1 "k8s.io/api/core/v1"
23+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2425
clusterutilv1 "sigs.k8s.io/cluster-api/util"
2526
v1beta1conditions "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions"
2627
"sigs.k8s.io/controller-runtime/pkg/client"
2728

2829
infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1"
30+
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/manager"
2931
)
3032

3133
var _ = Describe("VSphereClusterIdentity Reconciler", func() {
3234
controllerNamespace := testEnv.Manager.GetControllerManagerContext().Namespace
35+
if controllerNamespace != manager.DefaultPodNamespace {
36+
ns := &corev1.Namespace{
37+
ObjectMeta: metav1.ObjectMeta{
38+
Name: controllerNamespace,
39+
},
40+
}
41+
if err := testEnv.Client.Create(ctx, ns); !apierrors.IsAlreadyExists(err) {
42+
Expect(err).ToNot(HaveOccurred())
43+
}
44+
}
3345

3446
Context("Reconcile Normal", func() {
3547
It("should set the ownerRef on a secret and set Ready condition", func() {

0 commit comments

Comments
 (0)