Skip to content

Commit

Permalink
Set SkipNameValidation for controller tests
Browse files Browse the repository at this point in the history
As of controller-runtime 0.19.0, it validates if controller name is
unique. Because tests need to instantiate controller multiple times,
disable it.

Signed-off-by: Toshikuni Fukaya <[email protected]>
  • Loading branch information
toshipp committed Oct 24, 2024
1 parent f24b9ed commit e59ae86
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/controller/pie/pieprobe_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/config"
"sigs.k8s.io/controller-runtime/pkg/log"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)
Expand Down Expand Up @@ -152,9 +153,13 @@ var _ = Describe("PieProbe controller", func() {
}

BeforeEach(func() {
skipNameValidation := true
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{BindAddress: "0"},
Controller: config.Controller{
SkipNameValidation: &skipNameValidation,
},
})
Expect(err).NotTo(HaveOccurred())

Expand Down

0 comments on commit e59ae86

Please sign in to comment.