diff --git a/pkg/webhook/example_test.go b/pkg/webhook/example_test.go index 0deb382324..1c15a4455a 100644 --- a/pkg/webhook/example_test.go +++ b/pkg/webhook/example_test.go @@ -83,7 +83,7 @@ func Example() { // This example creates a webhook server that can be // ran without a controller manager. -func ExampleStandaloneServer() { +func ExampleServer_StartStandalone() { // Create a webhook server hookServer := &Server{ Port: 8443, @@ -105,7 +105,7 @@ func ExampleStandaloneServer() { // and runs it on a vanilla go HTTP server to demonstrate // how you could run a webhook on an existing server // without a controller manager. -func ExampleArbitraryHTTPServer() { +func ExampleStandaloneWebhook() { // Assume you have an existing HTTP server at your disposal // configured as desired (e.g. with TLS). // For this example just create a basic http.ServeMux @@ -144,6 +144,8 @@ func ExampleArbitraryHTTPServer() { mux.Handle("/validating", validatingHookHandler) // Run your handler - http.ListenAndServe(port, mux) + if err := http.ListenAndServe(port, mux); err != nil { + panic(err) + } } diff --git a/pkg/webhook/webhook_integration_test.go b/pkg/webhook/webhook_integration_test.go index e2a1d2b3b3..51e9162d50 100644 --- a/pkg/webhook/webhook_integration_test.go +++ b/pkg/webhook/webhook_integration_test.go @@ -144,7 +144,7 @@ var _ = Describe("Webhook", func() { Expect(srv.Shutdown(context.Background())).NotTo(HaveOccurred()) close(idleConnsClosed) }() - srv.Serve(listener) + _ = srv.Serve(listener) <-idleConnsClosed }()