Commit Graph

26 Commits

Author SHA1 Message Date
Cyrill Näf 78fb25a522 Update crossplane-runtime to 1.18
Signed-off-by: Cyrill Näf <cyrill.naef@gmail.com>
2024-11-14 07:50:13 +00:00
Nic Cope dba741619e Bump Kubernetes deps, buf, and provider-aws
These all had quite a lot of interactions so I had to do them together.

Note we can't bump to Kubernetes v0.31.0 because it's newer than what
the latest crossplane-runtime release is using. We'll need to update
crossplane-runtime first.

I'm also seriously questioning keeping the dependency on provider-aws.
It's massive and has a lot of painful dependencies to fix when we update
the import. On the other hand, I experimented with e.g. using
provider-nop or provider-kubernetes for examples and didn't like it.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-09-17 11:24:01 -07:00
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
Steven Borrelli 53155a2d18 update comments to match resource type
Signed-off-by: Steven Borrelli <steve@borrelli.org>
2024-05-20 14:03:52 -05:00
Steven Borrelli 434972f741 fix lint error
Signed-off-by: Steven Borrelli <steve@borrelli.org>
2024-05-20 13:59:50 -05:00
Steven Borrelli 8ff4cae190 add observedGeneration
Signed-off-by: Steven Borrelli <steve@borrelli.org>
2024-05-20 13:54:35 -05: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 82371e39a6 Clear out empty object metadata if it exists after conversion
Without this change any resource that has no ObjectMeta will end up with
an empty metadata (like "metadata": {}) when rendered. This is because
json serialization adds the generation field. We then delete it,
resulting in an empty metadata object.

This isn't actually so bad because Crossplane will always add a few
labels, owner refs, etc before the metadata becomes part of the SSA
fully-specified intent. So in reality we'll never ask the API server to
make metadata an empty object. It is misleading in unit tests though.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-10-30 15:47:14 -07:00
Nic Cope 810689042b Use a runtime.Scheme to load GVK using From
I don't love the package-scoped state here but this seems like the
nicest API to offer callers.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-10-30 00:08:48 -07: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 9fc84aa24d Demonstrate that MR structs marshal with extraneous fields
Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-10-30 00:08:45 -07:00
Steven Borrelli 66fe852bf9
Sync with upstream crossplane-runtime changes
* Bump crossplane-runtime
* Update GetInteger to handle floats locally
* Use new claim.Reference type

Signed-off-by: Steven Borrelli <steve@borrelli.org>
2023-10-24 14:16:20 -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 391e26d51d Make GetInteger work with 'normal' non-Kubernetes JSON data
Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-09-28 22:12:58 -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