Commit Graph

16 Commits

Author SHA1 Message Date
Clément Blaise c2fac0f7b2 Fix typos, update types and add comments
Signed-off-by: Clément Blaise <clementblaise@me.com>
2024-06-06 01:15:16 +08:00
Clément Blaise f3cde1bfc8 Add CredentialsType
Co-authored-by: Nic Cope <nicc@rk0n.org>
Signed-off-by: Clément Blaise <clementblaise@me.com>
2024-06-03 23:15:27 +08:00
Clément Blaise 12c319db27 Change Credential type
Signed-off-by: Clément Blaise <clementblaise@me.com>
2024-06-03 23:07:37 +08:00
Clément Blaise 7617361f7c Add credentials protobufs and helper
Signed-off-by: Clément Blaise <clementblaise@me.com>
2024-06-03 23:07:37 +08:00
Nic Cope 48e682947c Reject unknown fields when converting from Struct to Object
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>
2024-02-14 02:55:44 -08:00
Philippe Scorsolini 9e73fdc8bf
review
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2024-01-18 23:06:59 +00:00
Philippe Scorsolini bb797d14d3
feat: extra resources
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2024-01-18 09:17:43 +00:00
Nic Cope 09f878b7bf Use go-json-experiment (and hacks) to trim empty fields
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>
2023-10-30 00:08:48 -07:00
Nic Cope 0fbc5662fd Add an example of using structured types
Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-09-28 22:13:33 -07:00
Nic Cope d3170f88ed Better detect *unstructured.Unstructured
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>
2023-09-28 21:17:34 -07:00
Nic Cope efcec9694a Automatically fieldpath.Pave composite and composed resources
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>
2023-09-28 20:04:38 -07:00
Philippe Scorsolini 5b013ffc4d
feat: introduce logging and errors packages
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
2023-09-27 12:24:57 +02:00
Nic Cope d1dfe75ec7 Make NewDesiredComposedResource return a pointer
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>
2023-09-26 19:39:38 -07:00
Nic Cope 2b44902a15 Make Ready enum a string
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>
2023-09-17 18:49:01 -07:00
Nic Cope ef3a2e04d3 Remove DesiredComposedResources and ObserveComposedResources types
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>
2023-09-15 18:59:34 -07:00
Nic Cope 8dd124b7a5 Add the beginnings of a Function SDK
I'm sure this won't be close to the end shape of this SDK, but I want to
start somewhere. This is essentially a few utilities I found I wanted
when writing https://github.com/crossplane-contrib/function-patch-and-transform

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-09-12 05:45:19 -07:00