Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
ctx := webhook.WithOptions(signals.NewContext(), webhook.Options{
ServiceName: webhook.NameFromEnv(),
Port: webhook.PortFromEnv(8443),
SecretName: "operator-webhook-certs",
SecretName: webhook.CertsSecretNameFromEnv("operator-webhook-certs"),
})

sharedmain.WebhookMainWithContext(ctx, webhook.NameFromEnv(),
Expand Down
18 changes: 15 additions & 3 deletions vendor/knative.dev/pkg/webhook/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ import (
"strconv"
)

const portEnvKey = "WEBHOOK_PORT"
const (
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you manually changed this file: vendor/knative.dev/pkg/webhook/env.go?
It is a dependency of this repository. You shouldn't change it here at all.
If you propose a change in knative.dev/pkg, please submit your change in knative.dev/pkg first, then update the dependencies here in this repository.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realized that the pkg repository exist.
I will submit this PR to knative.dev/pkg first.

Thanks.

portEnvKey = "WEBHOOK_PORT"

// Webhook is the name of the override key used inside of the logging config for Webhook Controller.
const webhookNameEnv = "WEBHOOK_NAME"
// Webhook is the name of the override key used inside of the logging config for Webhook Controller.
webhookNameEnv = "WEBHOOK_NAME"

certsSecretNameEnv = "WEBHOOK_CERTS_SECRET_NAME"
)

// PortFromEnv returns the webhook port set by portEnvKey, or default port if env var is not set.
func PortFromEnv(defaultPort int) int {
Expand Down Expand Up @@ -54,3 +58,11 @@ If this is a process running on Kubernetes, then initialize this variable via:
value: webhook
`, webhookNameEnv))
}

func CertsSecretNameFromEnv(defaultCertsSecretName string) string {
secret := os.Getenv(certsSecretNameEnv)
if secret == "" {
return defaultCertsSecretName
}
return secret
}