-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⚠️ Deprecate admission.Validator and admission.Defaulter #2639
⚠️ Deprecate admission.Validator and admission.Defaulter #2639
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
f3d83a0
to
aa8a2b1
Compare
`admission.Validator/Defaulter` require to import controller-runtime into api packages. This is not recommended, as api packages should themselves not have any dependencies except to other api packages in order to make importing them easy without dependency issues and possibly incompatibilities. This change marks the two as deprecated. We are not going to remove them yet to give folks some time to migrate off them.
aa8a2b1
to
1c704b9
Compare
@alvaroaleman: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/lgtm Will kubebuilder need to change their scaffolding to improve this going forward? |
// +kubebuilder:webhook:path=/validate-chaosapps-metamagical-io-v1-chaospod,mutating=false,failurePolicy=fail,groups=chaosapps.metamagical.io,resources=chaospods,verbs=create;update,versions=v1,name=vchaospod.kb.io | ||
|
||
var _ webhook.Validator = &ChaosPod{} | ||
|
||
// ValidateCreate implements webhookutil.validator so a webhook will be registered for the type | ||
func (c *ChaosPod) ValidateCreate() (admission.Warnings, error) { | ||
log.Info("validate create", "name", c.Name) | ||
|
||
if c.Spec.NextStop.Before(&metav1.Time{Time: time.Now()}) { | ||
return nil, fmt.Errorf(".spec.nextStop must be later than current time") | ||
} | ||
return nil, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an example with the CustomValidator interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are existing examples in https://github.com/kubernetes-sigs/controller-runtime/tree/main/examples/builtins
/lgtm |
admission.Validator/Defaulter
require to import controller-runtime into api packages. This is not recommended, as api packages should themselves not have any dependencies except to other api packages in order to make importing them easy without dependency issues and possibly incompatibilities.This change marks the two as deprecated. We are not going to remove them yet to give folks some time to migrate off them.
Closes #2596