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

fixes to unknown field handling #113

Merged
merged 3 commits into from
Mar 5, 2024
Merged

fixes to unknown field handling #113

merged 3 commits into from
Mar 5, 2024

Conversation

scott-cotton
Copy link
Member

Unknown field handling prevents overwriting unknown fields with their default value, as can be problematic for example with TTL.

  • add it to resource plugin
  • make it apply only to spec

Unknown field handling prevents overwriting unknown fields with their
default value, as can be problematic for example with TTL.

- add it to resource plugin
- make it apply only to spec
Comment on lines 22 to 36
var (
name string
ok bool
spec any
)
switch x := un.(type) {
case map[string]any:
name, ok = x["name"].(string)
spec = x["spec"]
default:
}
if !ok {
return nil, errors.New("missing name or spec fields")
}
d, err := json.Marshal(spec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we place this logic into a function? (and call it from resourceplugin, routegroup and sandbox)

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, done.

Copy link
Contributor

@daniel-de-vera daniel-de-vera left a comment

Choose a reason for hiding this comment

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

LGTM

@scott-cotton scott-cotton merged commit 5b7981c into main Mar 5, 2024
@scott-cotton scott-cotton deleted the unknown-field-fixes branch March 5, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants