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

ControllerName validation helper #1412

Merged

Conversation

mlavacca
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:
A utility to check the Controller name validity has been added to apis//util/validation.

Which issue(s) this PR fixes:

Fixes #1410

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 27, 2022
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 27, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @mlavacca. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 27, 2022
Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

TBH I don't get the use case. Seems like each impl will make pick controllerName as a constant, and if its invalid they will pick a new one? Not sure why we need a Go helper...

I also don't mind though

apis/v1alpha2/util/validation/gatewayclass.go Outdated Show resolved Hide resolved
@mlavacca mlavacca force-pushed the controllername-validation-helper branch from 2f37607 to 8aab82d Compare September 27, 2022 14:26
@mlavacca
Copy link
Member Author

TBH I don't get the use case. Seems like each impl will make pick controllerName as a constant, and if its invalid they will pick a new one? Not sure why we need a Go helper...

Recently in the Kong implementation, we have had to make it customizable via argument. This helper is meant to validate the controllerName in such a use case.

@mlavacca mlavacca force-pushed the controllername-validation-helper branch from 8aab82d to fd0885b Compare September 27, 2022 14:42
@mlavacca mlavacca requested review from howardjohn and removed request for akankshakumari393 and howardjohn September 27, 2022 15:37
@mlavacca mlavacca requested review from sunjayBhatia and howardjohn and removed request for sunjayBhatia September 28, 2022 08:15
@mlavacca
Copy link
Member Author

mlavacca commented Sep 29, 2022

I'm not sure why, but re-asking the review to @howardjohn, @sunjayBhatia, and @akankshakumari393 removed the review request to @mikemorris and @keithmattix. The PR is ready for review and all the conversations have been resolved.

@akankshakumari393
Copy link
Member

Yeah it happens, If you request one, the others would be removed from review request.

@youngnick
Copy link
Contributor

For the case that people take the controllerName as an argument, having common code to validate seems like a great idea to me.

/approve

I'll leave the LGTM for someone else though.

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2022
Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

Code and idea LGTM, however one thing I would like to talk about possibly changing:

We're putting this in two places with the same regex. Having copied code is usually not ideal. We recently made changes to share types between v1alpha2 and v1beta1 to reduce some of these copies, I think we should do the same here.

An utility to check the Controller name validity has been added to
apis/<version>/util/validation.

Signed-off-by: Mattia Lavacca <[email protected]>
@mlavacca mlavacca force-pushed the controllername-validation-helper branch from fd0885b to 219ba50 Compare October 17, 2022 11:39
@mlavacca mlavacca requested review from shaneutt and removed request for howardjohn October 17, 2022 11:41
@mlavacca
Copy link
Member Author

We're putting this in two places with the same regex. Having copied code is usually not ideal. We recently made changes to share types between v1alpha2 and v1beta1 to reduce some of these copies, I think we should do the same here.

I factorized the regexp and kept only the v1beta1 instance.

Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

We should be able to share all the v1beta1 code backwards to v1alpha2, rather than just the regexp no?

@mlavacca mlavacca force-pushed the controllername-validation-helper branch from 219ba50 to 9438511 Compare October 18, 2022 14:24
@mlavacca
Copy link
Member Author

We should be able to share all the v1beta1 code backwards to v1alpha2, rather than just the regexp no?

Sure, I factorized the whole helper and removed the v1alpha2 test case as it is useless now.

@mlavacca mlavacca requested a review from shaneutt October 18, 2022 14:26
Signed-off-by: Mattia Lavacca <[email protected]>
@mlavacca mlavacca force-pushed the controllername-validation-helper branch from 9438511 to 0a51f09 Compare October 18, 2022 14:27
Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 18, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mlavacca, shaneutt, youngnick

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

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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ControllerName validation helper
7 participants