warn on extraneous keys used in func.yaml#3611
warn on extraneous keys used in func.yaml#3611knative-prow[bot] merged 1 commit intoknative:mainfrom
Conversation
|
Skipping CI for Draft Pull Request. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3611 +/- ##
==========================================
+ Coverage 56.27% 56.30% +0.03%
==========================================
Files 180 180
Lines 20522 20549 +27
==========================================
+ Hits 11548 11571 +23
- Misses 7773 7777 +4
Partials 1201 1201
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ddf6369 to
466cbd5
Compare
twoGiants
left a comment
There was a problem hiding this comment.
Looks good! Just add a few test cases covering the new conditional logic. Thank you 😸 👍
466cbd5 to
df47c5f
Compare
df47c5f to
5a0d73b
Compare
twoGiants
left a comment
There was a problem hiding this comment.
Looks good! Thank you for the tests.
I have just a minor nit => optional.
/approve
/lgtm
/hold for others
| if f.Root != "" { | ||
| if bb, readErr := os.ReadFile(filepath.Join(f.Root, FunctionFile)); readErr == nil { | ||
| unknownFieldsOnce.Do(func() { | ||
| var strict Function | ||
| if strictErr := yaml.UnmarshalStrict(bb, &strict); strictErr != nil { | ||
| fmt.Fprintf(os.Stderr, "Warning (unknown fields will be ignored):\n %v\n.\n", formatUnmarshalError(strictErr)) | ||
| } | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
nit: use early return
| if f.Root != "" { | |
| if bb, readErr := os.ReadFile(filepath.Join(f.Root, FunctionFile)); readErr == nil { | |
| unknownFieldsOnce.Do(func() { | |
| var strict Function | |
| if strictErr := yaml.UnmarshalStrict(bb, &strict); strictErr != nil { | |
| fmt.Fprintf(os.Stderr, "Warning (unknown fields will be ignored):\n %v\n.\n", formatUnmarshalError(strictErr)) | |
| } | |
| }) | |
| } | |
| } | |
| if f.Root == "" { | |
| return f, nil | |
| } | |
| if bb, readErr := os.ReadFile(filepath.Join(f.Root, FunctionFile)); readErr == nil { | |
| unknownFieldsOnce.Do(func() { | |
| var strict Function | |
| if strictErr := yaml.UnmarshalStrict(bb, &strict); strictErr != nil { | |
| fmt.Fprintf(os.Stderr, "Warning (unknown fields will be ignored):\n %v\n.\n", formatUnmarshalError(strictErr)) | |
| } | |
| }) | |
| } |
| // Migrate applies any necessary migrations, returning a new migrated | ||
| // version of the function. It is the caller's responsibility to | ||
| // .Write() the function to persist to disk. | ||
| // .Write() the function to persist to disk. Aditionaly it will warn on |
There was a problem hiding this comment.
typo: Aditionaly => Additionally
5a0d73b to
b2d0a34
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gauron99, matejvasek, twoGiants The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/unhold |
adding a warning for extraneous keys
when we have the latest (migrated) spec present, we do a strict Unmarshal (which errors on extraneous keys) and we print a warning like above.
Note that Im adding the "once" because NewFunction is actually called few times throughout a lets say "func deploy" call.