Commit Graph

21 Commits

Author SHA1 Message Date
Nic Cope 1f3ee551a0 Switch the SDK to use v1 protos
v1 is currently identical to v1beta1. Upstream we have automation that
makes sure the two protos are identical (apart from their package).

Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-08-16 13:20:45 -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 18b5431c81 Remove reflect and use returned type
Co-authored-by: Nic Cope <nicc@rk0n.org>
Signed-off-by: Clément Blaise <clementblaise@me.com>
2024-06-03 23:09:12 +08:00
Clément Blaise 3a3a3c9dfb Add function doc
Signed-off-by: Clément Blaise <clementblaise@me.com>
2024-06-03 23:07:37 +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 0115992df2 Refactor to GetCredential and check secret source
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 1335c4bd9c Fix error formatting for GetInput
Signed-off-by: Nic Cope <nicc@rk0n.org>
2024-02-17 14:20:19 -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 a11b5d9bfc Bump golangci-lint to v1.55.1
Notably this includes a handy new linter that warns when you don't use
GetFoo methods to access protobuf fields.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-10-25 16:13:34 -07:00
Philippe Scorsolini 46545057a8
Merge pull request #39 from negz/contextual 2023-10-13 18:11:28 +02: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
Nic Cope d23e2c8fb4 Make a non-nil map of desired XR connection details
This way even if the RunFunctionRequest doesn't include a desired XR,
GetDesiredComposedResource will return a datastructure that you can
mutate and return without fear of writing to a nil map.

Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-09-29 18:11:48 -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 073167e7c6 Load readiness from RunFunctionRequest
Signed-off-by: Nic Cope <nicc@rk0n.org>
2023-09-17 19:23:30 -07: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