Skip to content

Commit 10ba4ae

Browse files
committed
example-builtin: Refactor webhook setup to use ctrl.NewWebhookManagedBy and move logging to ctrl.SetLogger
Signed-off-by: suzi1037 <[email protected]>
1 parent 717293d commit 10ba4ae

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

examples/builtins/main.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,16 @@ import (
2424
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
2525

2626
ctrl "sigs.k8s.io/controller-runtime"
27-
"sigs.k8s.io/controller-runtime/pkg/builder"
2827
"sigs.k8s.io/controller-runtime/pkg/client/config"
2928
"sigs.k8s.io/controller-runtime/pkg/handler"
30-
"sigs.k8s.io/controller-runtime/pkg/log"
3129
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3230
"sigs.k8s.io/controller-runtime/pkg/manager"
3331
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
3432
"sigs.k8s.io/controller-runtime/pkg/source"
3533
)
3634

37-
func init() {
38-
log.SetLogger(zap.New())
39-
}
40-
4135
func main() {
36+
ctrl.SetLogger(zap.New())
4237
entryLog := ctrl.Log.WithName("entrypoint")
4338

4439
// Setup a Manager
@@ -65,7 +60,7 @@ func main() {
6560
os.Exit(1)
6661
}
6762

68-
if err := builder.WebhookManagedBy(mgr).
63+
if err := ctrl.NewWebhookManagedBy(mgr).
6964
For(&corev1.Pod{}).
7065
WithDefaulter(&podAnnotator{}).
7166
WithValidator(&podValidator{}).

0 commit comments

Comments
 (0)