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

Emit a warning when using missing field in FunctionSpec #4758

Conversation

koba1t
Copy link
Member

@koba1t koba1t commented Aug 12, 2022

fix #4399

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 12, 2022
@k8s-ci-robot
Copy link
Contributor

@koba1t: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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.

@koba1t koba1t force-pushed the feature/emit_a_warning_to_ignore_plugin branch from 950931f to 6aeaa75 Compare August 18, 2022 23:40
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 19, 2022
@koba1t koba1t force-pushed the feature/emit_a_warning_to_ignore_plugin branch 2 times, most recently from 8ac93c1 to 647d667 Compare August 19, 2022 01:13
@koba1t koba1t marked this pull request as ready for review August 19, 2022 01:14
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 19, 2022
@natasha41575
Copy link
Contributor

@annasong20 would you mind giving this one a quick review?

/cc @annasong20

@k8s-ci-robot
Copy link
Contributor

@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:

@annasong20 would you mind giving this one a quick review?

/cc @annasong20

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.

api/internal/plugins/fnplugin/fnplugin.go Outdated Show resolved Hide resolved
api/internal/plugins/fnplugin/fnplugin.go Outdated Show resolved Hide resolved
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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see now! Thanks

@koba1t koba1t force-pushed the feature/emit_a_warning_to_ignore_plugin branch 2 times, most recently from b95f33c to fef75f2 Compare August 26, 2022 15:29
@koba1t
Copy link
Member Author

koba1t commented Aug 26, 2022

hi @natasha41575
I fix error messages.
Could you check it if you have time?

Copy link
Contributor

@natasha41575 natasha41575 left a 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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn, _ := GetFunctionSpec(cfg)
fn, err := GetFunctionSpec(cfg)
assert.NoError(t, err)

Copy link
Contributor

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

Copy link
Member Author

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\"",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is awesome!

kyaml/fn/runtime/runtimeutil/runtimeutil_test.go Outdated Show resolved Hide resolved
kyaml/fn/runtime/runtimeutil/runtimeutil_test.go Outdated Show resolved Hide resolved
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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see now! Thanks

kyaml/fn/runtime/runtimeutil/runtimeutil_test.go Outdated Show resolved Hide resolved
kyaml/runfn/runfn_test.go Show resolved Hide resolved
@koba1t koba1t force-pushed the feature/emit_a_warning_to_ignore_plugin branch from fef75f2 to f8bee5c Compare September 3, 2022 00:28
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 3, 2022
@koba1t koba1t force-pushed the feature/emit_a_warning_to_ignore_plugin branch from f8bee5c to e49bf52 Compare September 3, 2022 00:29
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 3, 2022
@koba1t
Copy link
Member Author

koba1t commented Sep 3, 2022

hi @natasha41575
I fixed a few error handling.
Please recheck it in your free time.

@natasha41575
Copy link
Contributor

/lgtm
/approve

Thank you very much for the fix!

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

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 9, 2022
@k8s-ci-robot k8s-ci-robot merged commit 56a47bd into kubernetes-sigs:master Sep 9, 2022
@koba1t koba1t deleted the feature/emit_a_warning_to_ignore_plugin branch September 9, 2022 15:50
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

Do not silently ignore plugins when config has typo
3 participants