Skip to content

Commit

Permalink
Merge pull request #1016 from msiebuhr/fix-webhook-example
Browse files Browse the repository at this point in the history
🐛 Fix webhook example
  • Loading branch information
k8s-ci-robot authored Jun 23, 2020
2 parents 4836ec2 + 5db0b9d commit add0b64
Showing 1 changed file with 8 additions and 5 deletions.
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

0 comments on commit add0b64

Please sign in to comment.