Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add examples for passing data between resources #56

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading