-
Notifications
You must be signed in to change notification settings - Fork 209
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
Fully ignore unknown tags in ParseCommentTags #519
Conversation
1dbbfa0
to
ba9fe2a
Compare
Is that VALID, GOOD code or just code that exercised the existing behavior? |
@@ -2386,7 +2387,7 @@ func TestMarkerComments(t *testing.T) { | |||
// +k8s:validation:pattern="^foo$[0-9]+" | |||
StringValue string | |||
|
|||
// +k8s:validation:maxitems=10 | |||
// +k8s:validation:maxItems=10 |
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.
Wondering why this passed the test before?
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.
Because maxItems is never used to check anything in the test :( If the test had tried to exceed maxItems, it would have been allowed.
I could just remove this validation rules to simplify the test case..
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.
hmmm.. I think it is because the json.Unmarshal
is not case-sensitive. So when unmarshal the commentTags
here
kube-openapi/pkg/generators/markers.go
Line 411 in 9959940
if err = json.Unmarshal(out, &commentTags); err != nil { |
maxItems
and maxitems
both are parsed. So the test actually passes with here remain as maxitems
.
How about having a TODO and a more comprehensive test by a separate PR? i'm thinking maybe need to have an option for the testOpenAPITypeWriter
to cover "ignore unknown" in the openapi_test.go
.
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.
We should not rely on that, I think the JSON we use in k/k is not case-insensitve
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.
k/k is using https://github.com/kubernetes-sigs/json which is case sensitive
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'll follow up on this in a separate issue.
ba9fe2a
to
bb996bf
Compare
I dug deeper. One of the problem cases was for the |
bb996bf
to
2ce1b89
Compare
Edit PR comment to remote words about options? |
Thanks. Yes, that's misleading. Fixed. |
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
@@ -61,6 +63,30 @@ func (c *CELTag) Validate() error { | |||
return nil | |||
} | |||
|
|||
func isKnownTagCommentKey(key string) bool { |
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.
Could you comment this - Would be nice to explain the expected "grammar" for a key here.
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.
Sure, added.
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.
not pushed?
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.
oops, pushed now
2ce1b89
to
04b9783
Compare
Thanks! /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jpbetz, thockin 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 |
Fix
generators.ParseCommentTags
to not fail on parsing on tags that it ignores anyway.