crossplane / function-sdk-go

The Go SDK for composition functions
https://crossplane.io
Apache License 2.0
19 stars 13 forks source link

Reject unknown fields when converting from Struct to Object #124

Closed negz closed 6 months ago

negz commented 6 months ago

Description of your changes

Closes https://github.com/crossplane/function-sdk-go/pull/123 Closes https://github.com/crossplane/function-sdk-go/pull/121

This is mostly useful when a function loads its input from the RunFunctionRequest. Crossplane isn't (yet) aware of input schema and will send anything the user supplies. See https://github.com/crossplane-contrib/function-patch-and-transform/pull/91#issuecomment-1942672309.

Right now that could include extra unknown, misindented, or typod fields and those will be silently ignored by the function. With this change in place they will result in an error.

This code will also be used to load desired and observed resource state, but it's unlikely for those to be invalid.

This is a small behavior change, but I feel okay with it. The new behavior is safer, probably won't affect anyone, and we're pre 1.0.

I have:

How has this code been tested