https://github.com/crossplane/function-template-go
A template for writing a composition function in Go
https://github.com/crossplane/function-template-go
Last synced: 10 months ago
JSON representation
A template for writing a composition function in Go
- Host: GitHub
- URL: https://github.com/crossplane/function-template-go
- Owner: crossplane
- License: apache-2.0
- Created: 2023-09-15T03:43:41.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-08-20T22:03:44.000Z (10 months ago)
- Last Synced: 2025-08-21T00:11:58.007Z (10 months ago)
- Language: Go
- Homepage: https://crossplane.io
- Size: 156 KB
- Stars: 33
- Watchers: 6
- Forks: 36
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# function-template-go
[](https://github.com/crossplane/function-template-go/actions/workflows/ci.yml)
A template for writing a [composition function][functions] in [Go][go].
To learn how to use this template:
* [Follow the guide to writing a composition function in Go][function guide]
* [Learn about how composition functions work][functions]
* [Read the function-sdk-go package documentation][package docs]
If you just want to jump in and get started:
1. Replace `function-template-go` with your function in `go.mod`,
`package/crossplane.yaml`, and any Go imports. (You can also do this
automatically by running the `./init.sh ` script.)
1. Update `input/v1beta1/` to reflect your desired input (and run `go generate ./...`)
1. Add your logic to `RunFunction` in `fn.go`
1. Add tests for your logic in `fn_test.go`
1. Update this file, `README.md`, to be about your function!
This template uses [Go][go], [Docker][docker], and the [Crossplane CLI][cli] to
build functions.
```shell
# Run code generation - see input/generate.go
$ go generate ./...
# Run tests - see fn_test.go
$ go test ./...
# Build the function's runtime image - see Dockerfile
$ docker build . --tag=runtime
# Build a function package - see package/crossplane.yaml
$ crossplane xpkg build -f package --embed-runtime-image=runtime
```
[functions]: https://docs.crossplane.io/latest/concepts/composition-functions
[go]: https://go.dev
[function guide]: https://docs.crossplane.io/knowledge-base/guides/write-a-composition-function-in-go
[package docs]: https://pkg.go.dev/github.com/crossplane/function-sdk-go
[docker]: https://www.docker.com
[cli]: https://docs.crossplane.io/latest/cli