Skip to content

Commit

Permalink
feat(labels) add generic validate label
Browse files Browse the repository at this point in the history
  • Loading branch information
rainest committed Apr 12, 2024
1 parent 80424f3 commit 81f1cd0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/admission/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,19 @@ func (h RequestHandler) handleSecret(
// referenced secret, labeled or not.

// plugin configuration secrets
if _, hasPluginLabel := secret.Labels[labels.ValidateLabel]; hasPluginLabel {
switch validate := secret.Labels[labels.ValidateLabel]; labels.ValidateType(validate) {
case labels.PluginValidate:
ok, message, err := h.checkReferrersOfSecret(ctx, &secret)
if err != nil {
return responseBuilder.Allowed(false).WithMessage(fmt.Sprintf("failed to validate other objects referencing the secret: %v", err)).Build(), err
}
if !ok {
return responseBuilder.Allowed(false).WithMessage(message).Build(), nil
}
default:
// TODO this duplicates the above plugin handling block. prior to 3.2, the admission webhook ingested all
// Secrets and used this to validate updates to plugin configuration. this non-labeled case is retained
// for environments that still use ingest all configuration.
ok, message, err := h.checkReferrersOfSecret(ctx, &secret)
if err != nil {
return responseBuilder.Allowed(false).WithMessage(fmt.Sprintf("failed to validate other objects referencing the secret: %v", err)).Build(), err
Expand Down

0 comments on commit 81f1cd0

Please sign in to comment.