|
1 |
| -# function-template-go |
2 |
| -[](https://github.com/crossplane/function-template-go/actions/workflows/ci.yml) |
3 |
| - |
4 |
| -A template for writing a [composition function][functions] in [Go][go]. |
5 |
| - |
6 |
| -To learn how to use this template: |
7 |
| - |
8 |
| -* [Follow the guide to writing a composition function in Go][function guide] |
9 |
| -* [Learn about how composition functions work][functions] |
10 |
| -* [Read the function-sdk-go package documentation][package docs] |
11 |
| - |
12 |
| -If you just want to jump in and get started: |
13 |
| - |
14 |
| -1. Replace `function-template-go` with your function in `go.mod`, |
15 |
| - `package/crossplane.yaml`, and any Go imports. (You can also do this |
16 |
| - automatically by running the `./init.sh <function-name>` script.) |
17 |
| -1. Update `input/v1beta1/` to reflect your desired input (and run `go generate`) |
18 |
| -1. Add your logic to `RunFunction` in `fn.go` |
19 |
| -1. Add tests for your logic in `fn_test.go` |
20 |
| -1. Update this file, `README.md`, to be about your function! |
21 |
| - |
22 |
| -This template uses [Go][go], [Docker][docker], and the [Crossplane CLI][cli] to |
23 |
| -build functions. |
| 1 | +# function-sequencer |
| 2 | + |
| 3 | +Function Sequencer is a Crossplane function that enables Composition authors to define sequencing rules delaying the |
| 4 | +creation of resources until other resources are ready. |
| 5 | + |
| 6 | +For example, the pipeline step below, will ensure that `second-resource` and `third-resource` not to be created until |
| 7 | +the `first-resource` is ready. |
| 8 | + |
| 9 | +```yaml |
| 10 | + - step: sequence-creation |
| 11 | + functionRef: |
| 12 | + name: function-sequencer |
| 13 | + input: |
| 14 | + apiVersion: template.fn.crossplane.io/v1beta1 |
| 15 | + kind: Input |
| 16 | + rules: |
| 17 | + - sequence: |
| 18 | + - first-resource |
| 19 | + - second-resource |
| 20 | + - sequence: |
| 21 | + - first-resource |
| 22 | + - third-resource |
| 23 | +``` |
24 | 24 |
|
25 |
| -```shell |
26 |
| -# Run code generation - see input/generate.go |
27 |
| -$ go generate ./... |
| 25 | +See `example/composition.yaml` for a complete example. |
28 | 26 |
|
29 |
| -# Run tests - see fn_test.go |
30 |
| -$ go test ./... |
| 27 | +## Installation |
31 | 28 |
|
32 |
| -# Build the function's runtime image - see Dockerfile |
33 |
| -$ docker build . --tag=runtime |
| 29 | +Currently it could be installed as follows: |
34 | 30 |
|
35 |
| -# Build a function package - see package/crossplane.yaml |
36 |
| -$ crossplane xpkg build -f package --embed-runtime-image=runtime |
37 | 31 | ```
|
| 32 | +apiVersion: pkg.crossplane.io/v1beta1 |
| 33 | +kind: Function |
| 34 | +metadata: |
| 35 | + name: function-sequencer |
| 36 | +spec: |
| 37 | + package: xpkg.upbound.io/hasan/function-sequencer:v0.0.3 |
| 38 | +``` |
| 39 | + |
38 | 40 |
|
39 |
| -[functions]: https://docs.crossplane.io/latest/concepts/composition-functions |
40 |
| -[go]: https://go.dev |
41 |
| -[function guide]: https://docs.crossplane.io/knowledge-base/guides/write-a-composition-function-in-go |
42 |
| -[package docs]: https://pkg.go.dev/github.com/crossplane/function-sdk-go |
43 |
| -[docker]: https://www.docker.com |
44 |
| -[cli]: https://docs.crossplane.io/latest/cli |
0 commit comments