Skip to content

🐛 Fix webhook example #1016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pkg/webhook/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

var (
mgr ctrl.Manager
)

func Example() {
// Build webhooks
// These handlers could be also be implementations
Expand All @@ -48,6 +44,13 @@ func Example() {
}),
}

// Create a manager
// Note: GetConfigOrDie will os.Exit(1) w/o any message if no kube-config can be found
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{})
if err != nil {
panic(err)
}

// Create a webhook server.
hookServer := &Server{
Port: 8443,
Expand All @@ -61,7 +64,7 @@ func Example() {
hookServer.Register("/validating", validatingHook)

// Start the server by starting a previously-set-up manager
err := mgr.Start(ctrl.SetupSignalHandler())
err = mgr.Start(ctrl.SetupSignalHandler())
if err != nil {
// handle error
panic(err)
Expand Down