This example creates a webhook server that can be ran without a controller manager. Note that this assumes and requires a valid TLS cert and key at the default locations tls.crt and tls.key.
()
| 87 | // cert and key at the default locations |
| 88 | // tls.crt and tls.key. |
| 89 | func ExampleServer_Start() { |
| 90 | // Create a webhook server |
| 91 | hookServer := NewServer(Options{ |
| 92 | Port: 8443, |
| 93 | }) |
| 94 | |
| 95 | // Register the webhooks in the server. |
| 96 | hookServer.Register("/mutating", mutatingHook) |
| 97 | hookServer.Register("/validating", validatingHook) |
| 98 | |
| 99 | // Start the server without a manger |
| 100 | err := hookServer.Start(signals.SetupSignalHandler()) |
| 101 | if err != nil { |
| 102 | // handle error |
| 103 | panic(err) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // This example creates a standalone webhook handler |
| 108 | // and runs it on a vanilla go HTTP server to demonstrate |
nothing calls this directly
no test coverage detected
searching dependent graphs…