From c84479e0974d7acf955d2aca076bf47ac04f5c00 Mon Sep 17 00:00:00 2001 From: Andreas Fritzler Date: Wed, 30 Oct 2024 13:57:06 +0100 Subject: [PATCH] Fix default webhook port in test suite --- internal/controller/suite_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index d21bbbe..2d3ea5c 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -8,9 +8,12 @@ import ( "fmt" "path/filepath" "runtime" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" "testing" "time" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/config" @@ -123,6 +126,7 @@ func SetupTest() *corev1.Namespace { Expect(k8sClient.Create(ctx, ns)).To(Succeed(), "failed to create test namespace") DeferCleanup(k8sClient.Delete, ns) + webhookInstallOptions := &testEnv.WebhookInstallOptions k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme.Scheme, Controller: config.Controller{ @@ -130,6 +134,14 @@ func SetupTest() *corev1.Namespace { // since all tests need a dedicated controller SkipNameValidation: ptr.To(true), }, + WebhookServer: webhook.NewServer(webhook.Options{ + Host: webhookInstallOptions.LocalServingHost, + Port: 8082, + CertDir: webhookInstallOptions.LocalServingCertDir, + }), + Metrics: server.Options{ + BindAddress: ":8083", + }, }) Expect(err).ToNot(HaveOccurred())