README
¶
function-sdk-go
The Go SDK for writing composition functions.
This SDK is currently a beta. We try to avoid breaking changes, but it will not have a stable API until it reaches v1.0.0. It follows the same contributing guidelines as Crossplane.
To learn how to use this SDK:
- Follow the guide to writing a composition function in Go
- Learn about how composition functions work
- Read the package documentation
If you just want to jump in and get started, consider using the function-template-go template repository.
Documentation
¶
Overview ¶
Package function is an SDK for building Composition Functions.
Example ¶
Output: {"meta":{"ttl":"60s"},"desired":{"resources":{"new":{"resource":{"apiVersion":"example.org/v1","kind":"CoolResource","metadata":{"labels":{"coolness":"high"}},"spec":{"widgets":9001}}}}},"conditions":[{"type":"FunctionSuccess","status":"STATUS_CONDITION_TRUE","reason":"Success","target":"TARGET_COMPOSITE_AND_CLAIM"}]}
Index ¶
Examples ¶
Constants ¶
const ( DefaultNetwork = "tcp" DefaultAddress = ":9443" DefaultMaxRecvMsgSize = 1024 * 1024 * 4 )
Default ServeOptions.
Variables ¶
This section is empty.
Functions ¶
func Serve ¶
func Serve(fn v1.FunctionRunnerServiceServer, o ...ServeOption) error
Serve the supplied Function by creating a gRPC server and listening for RunFunctionRequests. Blocks until the server returns an error.
Types ¶
type BetaServer ¶ added in v0.3.0
type BetaServer struct { v1beta1.UnimplementedFunctionRunnerServiceServer // contains filtered or unexported fields }
A BetaServer is a v1beta1 FunctionRunnerServiceServer that wraps an identical v1 FunctionRunnerServiceServer. This requires the v1 and v1beta1 protos to be identical.
Functions were promoted from v1beta1 to v1 in Crossplane v1.17. Crossplane v1.16 and earlier only sends v1beta1 RunFunctionRequests. Functions should use the BetaServer for backward compatibility, to support Crossplane v1.16 and earlier.
func ServeBeta ¶ added in v0.3.0
func ServeBeta(s v1.FunctionRunnerServiceServer) *BetaServer
ServeBeta returns a v1beta1.FunctionRunnerServiceServer that wraps the suppled v1.FunctionRunnerServiceServer.
func (*BetaServer) RunFunction ¶ added in v0.3.0
func (s *BetaServer) RunFunction(ctx context.Context, req *v1beta1.RunFunctionRequest) (*v1beta1.RunFunctionResponse, error)
RunFunction calls the RunFunction method of the wrapped v1.FunctionRunnerServiceServer. It converts from v1beta1 to v1 and back by round-tripping through protobuf marshaling.
type ServeOption ¶
type ServeOption func(o *ServeOptions) error
A ServeOption configures how a Function is served.
func Insecure ¶
func Insecure(insecure bool) ServeOption
Insecure specifies whether this Function should be served insecurely - i.e. without mTLS authentication. This is only useful for testing and development. Crossplane will always send requests using mTLS.
func Listen ¶
func Listen(network, address string) ServeOption
Listen configures the network, address and maximum message size on which the Function will listen for RunFunctionRequests.
func MTLSCertificates ¶
func MTLSCertificates(dir string) ServeOption
MTLSCertificates specifies a directory from which to load mTLS certificates. The directory must contain the server certificate (tls.key and tls.crt), as well as a CA certificate (ca.crt) that will be used to authenticate clients.
func MaxRecvMessageSize ¶ added in v0.3.0
func MaxRecvMessageSize(sz int) ServeOption
MaxRecvMessageSize returns a ServeOption to set the max message size in bytes the server can receive. If this is not set, gRPC uses the default limit.
type ServeOptions ¶
type ServeOptions struct { Network string Address string MaxRecvMsgSize int Credentials credentials.TransportCredentials }
ServeOptions configure how a Function is served.
Directories
¶
Path | Synopsis |
---|---|
Package context contains utilities for working with Function context.
|
Package context contains utilities for working with Function context. |
Package errors is a github.com/pkg/errors compatible API for native errors.
|
Package errors is a github.com/pkg/errors compatible API for native errors. |
Package logging provides function's recommended logging interface.
|
Package logging provides function's recommended logging interface. |
proto
|
|
Package request contains utilities for working with RunFunctionRequests.
|
Package request contains utilities for working with RunFunctionRequests. |
Package resource contains utilities to convert protobuf representations of Crossplane resources to unstructured Go types, often with convenient getters and setters.
|
Package resource contains utilities to convert protobuf representations of Crossplane resources to unstructured Go types, often with convenient getters and setters. |
composed
Package composed contains an unstructured composed resource.
|
Package composed contains an unstructured composed resource. |
composite
Package composite contains an unstructured composite resource (XR).
|
Package composite contains an unstructured composite resource (XR). |
Package response contains utilities for working with RunFunctionResponses.
|
Package response contains utilities for working with RunFunctionResponses. |