Commit Graph

6 Commits

Author SHA1 Message Date
Nic Cope ffe3c155b4 Handle nil context fields, not just a nil context
Found while testing https://github.com/crossplane-contrib/function-patch-and-transform/pull/17

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-10-16 16:28:38 -07:00
Nic Cope 0eb69ebaea Support injecting Function environment via context
This is the Go SDK end of https://github.com/crossplane/crossplane/pull/4632

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-10-12 18:29:31 -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 fce65c0f3f Make desired resources map values pointers to struct
This makes it possible to mutate struct values while iterating over the
map of composed resources. I found myself naturally wanting to do this
while writing a Function. e.g.:

desired, _ = request.GetDesiredComposedResources(req)

for _, dr := range desired {
	dr.Ready = resource.ReadyTrue
}

_ = response.SetDesiredComposedResources(desired)

I haven't made the same change for observed resources, since they're
supposed to be read-only to a Function.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-09-15 19:01:21 -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