Skip to content

Commit

Permalink
docs: add examples for passing data between resources
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <xpf6677@163.com>
  • Loading branch information
Peefy committed Mar 28, 2024
1 parent be7a3a7 commit 6dc00da
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/resources/pass_data/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run:
crossplane beta render xr.yaml composition.yaml functions.yaml -r
31 changes: 31 additions & 0 deletions examples/resources/pass_data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Example Manifests

You can run your function locally and test it using `crossplane beta render`
with these example manifests.

```shell
# Run the function locally
$ go run . --insecure --debug
```

```shell
# Then, in another terminal, call it with these example manifests
$ crossplane beta render xr.yaml composition.yaml functions.yaml -r
---
apiVersion: nopexample.org/v1
kind: XSubnetwork
metadata:
annotations:
nobu.dev/app: someapp
nobu.dev/cueified: "true"
name: test-xrender
spec:
forProvider:
network: somenetwork
---
apiVersion: render.crossplane.io/v1beta1
kind: Result
message: updated xr ":XSubnetwork"
severity: SEVERITY_NORMAL
step: normal
```
42 changes: 42 additions & 0 deletions examples/resources/pass_data/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: function-template-go
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: XR
mode: Pipeline
pipeline:
- step: normal1
functionRef:
name: kcl-function
input:
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: basic
spec:
target: Resources
source: |
{
apiVersion: "nopexample.org/v1"
metadata.name = "resource1"
spec.atProvider.network: "somenetwork"
}
- step: normal2
functionRef:
name: kcl-function
input:
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: basic
spec:
target: Resources
source: |
{
apiVersion: "nopexample.org/v1"
metadata.name = "resource2"
spec.forProvider = option("params").dcds["resource1"].Resource.spec.atProvider
}
9 changes: 9 additions & 0 deletions examples/resources/pass_data/functions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: kcl-function
annotations:
# This tells crossplane beta render to connect to the function locally.
render.crossplane.io/runtime: Development
spec:
package: xpkg.upbound.io/crossplane-contrib/function-kcl:latest
5 changes: 5 additions & 0 deletions examples/resources/pass_data/xr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Replace this with your XR!
apiVersion: nopexample.org/v1
kind: XSubnetwork
metadata:
name: test-xrender

0 comments on commit 6dc00da

Please sign in to comment.