Skip to content

Commit

Permalink
Fix default webhook port in test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler committed Oct 30, 2024
1 parent 350bd4b commit c84479e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -123,13 +126,22 @@ 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{
// need to skip unique controller name validation
// 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())

Expand Down

0 comments on commit c84479e

Please sign in to comment.