-
Notifications
You must be signed in to change notification settings - Fork 42.4k
Add validate support for list kind #14726
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
Add validate support for list kind #14726
Conversation
|
Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist") If this message is too spammy, please complain to ixdy. |
|
Labelling this PR as size/M |
pkg/api/validation/schema.go
Outdated
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.
Isn't obj.(map[]) exactly what fields is?
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.
Do not do this bare type assertion without checking the type of obj.
|
cc @kubernetes/kubectl |
pkg/api/validation/schema.go
Outdated
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.
Are you doing this because of runtime.Unstructured? It would be better to just use runtime.Unstructured directly here, to be consistent with the rest of the list handling code.
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.
Another bare type assertion-- I'll stop mentioning them. All of these should look like:
if got, ok := item.(map[string]interface{}); ok {
doThing()
}Or variations thereof.
|
Filed #14775 re. tests for the feature. We'll need to cherrypick this into the 1.1 branch after it merges. |
7ba35ce to
f2225dd
Compare
|
@lavalamp @bgrant0607 @liggitt @deads2k @smarterclayton Thanks for review. I have adjusted this code and add some type checking. And I can't found an api which can decode the
|
ec0c92e to
91ffed3
Compare
|
runtime.IsList supporting runtime.Unstructured was the original intent of On Sep 30, 2015, at 8:53 AM, Zichang Lin notifications@github.com wrote: @lavalamp https://github.com/lavalamp @bgrant0607
— |
pkg/api/validation/schema.go
Outdated
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.
Give the index of the list that is failing. for i, item := range items....
|
Minor comments on the code. Please add a test that exercises this: positive and negative. I suspect that I'll create a followup issue to do validation with |
pkg/api/validation/schema.go
Outdated
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.
In thinking about this, I'd really like to have this loop check every item even if an early one fails. You can return a NewAggregate after the for loop. That way I can get all my failures at once instead of stumbling through one at a time.
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.
Yes, I'm thinking about this too. It's better to check every item in one time.
91ffed3 to
038a794
Compare
|
Next I will add test and do validation with Unstructured. I'll take a vacation next week. So I can't code for about one week. But discussing is ok. |
|
@k8s-bot ok to test |
|
GCE e2e test build/test passed for commit 755d740. |
|
The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label? |
|
@liggitt can you add the tag? |
|
Please merge. Then I can go on #15085 . |
|
The merge robot seems not working. @k8s-oncall, can we merge this manually? |
|
The merge robot was working earlier today. Sometime in the last few hours the UI has change significantly and the PR search box doesn't show any results for this PR. /cc @brendandburns |
|
/cc @lavalamp |
|
I started up a new version about 30 mins ago. It seems to not be aware of this PR at all. |
|
Probably worth some manual debugging before we merge. If its still not in the queue tomorrow afternoon, we'll manually merge it. |
|
oh ok this is in the queue dashboard now. It's in the (much shorter) queue of things that will be retested & merged. |
|
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
|
GCE e2e test build/test passed for commit 755d740. |
|
Automatic merge from submit-queue |
Auto commit by PR queue bot
…4726-upstream-release-1.1 Auto commit by PR queue bot
…pick-of-#14726-upstream-release-1.1 Auto commit by PR queue bot
…pick-of-#14726-upstream-release-1.1 Auto commit by PR queue bot
fix #13812
@bgrant0607