Skip to content
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

Merged

Conversation

alvaroaleman
Copy link
Member

@alvaroaleman alvaroaleman commented Jan 6, 2024

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

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 6, 2024
`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.
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jan 7, 2024

@alvaroaleman: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-controller-runtime-apidiff 1c704b9 link false /test pull-controller-runtime-apidiff

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.

@troy0820
Copy link
Member

troy0820 commented Jan 7, 2024

/lgtm

Will kubebuilder need to change their scaffolding to improve this going forward?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 7, 2024
@k8s-ci-robot k8s-ci-robot merged commit 5c21730 into kubernetes-sigs:main Jan 7, 2024
8 of 9 checks passed
@alvaroaleman alvaroaleman deleted the deprecate-validator branch January 8, 2024 14:23
Comment on lines -65 to -77
// +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
}
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sbueringer
Copy link
Member

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes to webhook.Validator pattern cause version update problems
5 participants