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.
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.
https://github.com/crossplane-contrib/function-patch-and-transform/pull/91#issuecomment-1942672309
Signed-off-by: Nic Cope <nicc@rk0n.org>
This is necessary for functions to be able to return JSON (as
structpb.Struct) that can be used as server side apply fully specified
intent. Without it we include empty structs that are non-nil, even if
they have the omitempty marker.
Signed-off-by: Nic Cope <nicc@rk0n.org>
We don't need the GetUnstructured interface since any type that has it
embeds Unstructured, and lets us get its object directly.
Signed-off-by: Nic Cope <nicc@rk0n.org>
This makes it more convenient and discoverable to get and set arbitrary
unstructured data from a composed or composite resource.
Signed-off-by: Nic Cope <nicc@rk0n.org>
You're most likely going to want to add this to the map returned by
request.GetDesiredComposedResources then later pass that to
response.SetDesiredComposedResources. The map in question is a map of
resource name to *resource.DesiredComposed, so it's easiest if this
returns that type.
Signed-off-by: Nic Cope <nicc@rk0n.org>
This lets us print it (e.g. in logs) in a human-readable way. I
considered using stringer to generate String() methods, but I don't
think we really care about the size/perf benefits of this enum being an
integer.
Signed-off-by: Nic Cope <nicc@rk0n.org>
These just served to obfuscate what the types actually were - a map of
resource name to observed/desired composed resource structs.
Signed-off-by: Nic Cope <nicc@rk0n.org>