-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Emit a warning when using missing field in FunctionSpec #4758
Emit a warning when using missing field in FunctionSpec #4758
Conversation
Skipping CI for Draft Pull Request. |
@koba1t: This PR has multiple commits, and the default merge method is: merge. 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. |
950931f
to
6aeaa75
Compare
8ac93c1
to
647d667
Compare
@annasong20 would you mind giving this one a quick review? /cc @annasong20 |
@natasha41575: GitHub didn't allow me to request PR reviews from the following users: annasong20. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
err = yaml.Unmarshal([]byte(s), &fs) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "%v\n", err) | ||
if err := k8syaml.UnmarshalStrict([]byte(s), &fs); err != nil { |
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.
Why do we need to use k8syaml 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.
We need strictly convert Yaml to Struct, but "sigs.k8s.io/kustomize/kyaml/yaml"
doesn't support this.
So I think we need to use UnmarshalStrict()
from k8syaml.
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 see now! Thanks
b95f33c
to
fef75f2
Compare
hi @natasha41575 |
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.
This is looking pretty good! Some nits
@@ -1394,7 +1401,7 @@ metadata: | |||
if !assert.NoError(t, err) { | |||
return | |||
} | |||
fn := GetFunctionSpec(cfg) | |||
fn, _ := GetFunctionSpec(cfg) |
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.
fn, _ := GetFunctionSpec(cfg) | |
fn, err := GetFunctionSpec(cfg) | |
assert.NoError(t, err) |
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.
This also applies to lines 1323 and 1542.
If you are expecting an error in one of these places,, you can do assert.Error(t, err)
instead
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 fix it.
`, | ||
}, | ||
}, | ||
error: "config.kubernetes.io/function unmarshal error: error unmarshaling JSON: while decoding JSON: json: unknown field \"containeeer\"", |
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.
This is awesome!
err = yaml.Unmarshal([]byte(s), &fs) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "%v\n", err) | ||
if err := k8syaml.UnmarshalStrict([]byte(s), &fs); err != nil { |
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 see now! Thanks
fef75f2
to
f8bee5c
Compare
f8bee5c
to
e49bf52
Compare
hi @natasha41575 |
/lgtm Thank you very much for the fix! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: koba1t, natasha41575 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 #4399