-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support mixed case Kind #1133
Support mixed case Kind #1133
Conversation
/hold |
Any thoughts @mengqiy @DirectXMan12 @Liujingfang1 ? /assign @mengqiy @DirectXMan12 @Liujingfang1 |
go.mod
Outdated
@@ -3,19 +3,17 @@ module sigs.k8s.io/kubebuilder | |||
go 1.12 | |||
|
|||
require ( |
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.
Update the go.mo and go.sum shows not be part of the scope of this PR.
I'd recommend you revert it and ensure that your branch is rebased with the master.
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.
Hi @mariantalla,
I still not getting why the modules need to be updated with these changes. So, I'd suggest to you:
- Ensure that the branch is rebased with master
- Revert the changes of go.mod and go.sum
Also, has nothing here to update the testdata. But, in order to test/check the change and be ensure I'd run make generate
as well.
Thanks everyone for the comments. There's indeed a couple of follow-ups before this is on its way to merge (I've updated the PR description so it's clearer what work is left). At the moment I was curious to hear how folks felt towards using |
Following the advice in #1048 (comment) (thanks @camilamacedo86 for the pointer), we've removed dependencies on apimachinery. |
The Travis error seems not to be related to this PR but to #1169 |
oops, forgot to |
It("should fail if the Kind is not pascal cased", func() { | ||
// Base case | ||
instance := &Resource{Group: "crew", Kind: "FirstMate", Version: "v1"} | ||
It("should succeed if the Kind is valid, according to core Kubernetes", func() { |
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.
IHMO the existent KInds check should pass.
Here for example : #1019 is for we allow AWSCluster
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.
Agreed; this PR relaxes Kind
validation (to bring it in line with the way it happens in core k8s). Previous passing tests continue to pass, and some previously failing should no longer fail (e.g. this one). Or am I missing something? 🤔
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.
The validation obtained is not the correct one for we check the kinds. If you use the correct one the only change here will be adding more one test to ensure that AWSCluster
will pass. Also, note that is required to remove the pascalze as well since it is not something check-in k8s API too.
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.
Following my suggestion to solve it.
- Remove the Pascalize
- Use the func https://github.com/kubernetes/apimachinery/blob/ced427e1ea5fdd2d307fa083f960961ceff71b65/pkg/util/validation/validation.go#L123 from k8s.io/apimachinery to check the Kind.
- Then, add a unit test with the same Kind used in the issue that this PR has the purpose to solve
AWSxpto
Thanks for the comments @camilamacedo86 ! I've responded inline; but just to make sure I got your last suggestion right:
I think this is happening here; where there other spots it needs to change?
Kind validation now uses IsDns1350Label, same as in core kubernetes
I think this test covers that case, is there something missing? |
👋 Is there anything else missing here? |
I think you may want to rebase to solve the Travis issue and benefit from all the added lint checks that were added in the meantime. |
whoops, lost track of this. Can merge after rebase. /assign @mengqiy |
@mariantalla Sorry for the delay on this PR. |
With the recent scaffolding it may be easier to branch from master and copy-paste your checks. |
Thanks! I'll make a start at rebasing, will poke you if it all goes wrong @Adirio :) |
Did a |
We should probably add a test to Travis that checks that |
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.
I ended up wondering why 2 different DNS RFCs are used. Is Kubernetes using both or did it change to one of them and we still have the outdated version?
Otherwise, LGTM. |
The implementation * uses the same validation logic that runs against `Kind` in apimachinery; i.e. allows any `Kind` value that, when converted to lowercase, is a valid DNS-1035 label. * additionally requires that `Kind`s start with an uppercase character, to ensure they map to exported types. Co-Authored-By: Hannes Hörl <[email protected]> Co-Authored-By: Camila Macedo <[email protected]>
@mariantalla: 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. |
/retest |
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.
/lgtm
for me wdyt @DirectXMan12 and @mengqiy ?
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mariantalla, mengqiy 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 |
This PR should address issues #1019 and #1091.
The implementation uses the validation logic that runs against
Kind
inapimachinery; i.e. allows any
Kind
value that, when converted tolowercase, is a valid DNS-1035 label.
Reusing that logic instead of reimplementing it helps with ensuring that
the two (i.e.
Kind
validation in core Kubernetes andKind
validationin kubebuilder) are as similar as possible.
Would love feedback on:
k8s.io/apimachinery
logic vs continuing to extend the validation logic in kubebuilder.Validate()
more broadly, to use available logic ink8s.io/apimachinery
?Remaining work in this PR:
(once the approach seems reasonable)