generated from crossplane/function-template-go
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from Wompipomp/add-conditions-and-events
Add conditions and events
- Loading branch information
Showing
19 changed files
with
697 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,6 @@ vendor/ | |
.kclvm | ||
.DS_store | ||
package/*.xpkg | ||
|
||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
run: | ||
crossplane render --verbose xr.yaml composition.yaml functions.yaml -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Example Manifests | ||
|
||
You can run your function locally and test it using `crossplane 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 render --verbose xr.yaml composition.yaml functions.yaml -r --extra-resources extra_resources.yaml | ||
--- | ||
--- | ||
apiVersion: example.crossplane.io/v1beta1 | ||
kind: XR | ||
metadata: | ||
name: example | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2024-01-01T00:00:00Z" | ||
message: 'Unready resources: another-awesome-dev-bucket, my-awesome-dev-bucket' | ||
reason: Creating | ||
status: "False" | ||
type: Ready | ||
--- | ||
apiVersion: example/v1alpha1 | ||
kind: Foo | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: another-awesome-dev-bucket | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: another-awesome-dev-bucket | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
--- | ||
apiVersion: example/v1alpha1 | ||
kind: Foo | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: my-awesome-dev-bucket | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: my-awesome-dev-bucket | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: Composition | ||
metadata: | ||
name: function-template-go | ||
spec: | ||
compositeTypeRef: | ||
apiVersion: example.crossplane.io/v1beta1 | ||
kind: XR | ||
mode: Pipeline | ||
pipeline: | ||
- step: normal | ||
functionRef: | ||
name: kcl-function | ||
input: | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLInput | ||
metadata: | ||
annotations: | ||
"krm.kcl.dev/default_ready": "True" | ||
name: basic | ||
spec: | ||
source: | | ||
oxr = option("params").oxr | ||
dxr = { | ||
**oxr | ||
} | ||
conditions = { | ||
apiVersion: "meta.krm.kcl.dev/v1alpha1" | ||
kind: "Conditions" | ||
conditions = [ | ||
{ | ||
target: "CompositeAndClaim" | ||
force: False | ||
condition = { | ||
type: "DatabaseReady" | ||
status: "False" | ||
reason: "FailedToCreate" | ||
message: "Encountered an error creating the database" | ||
} | ||
} | ||
] | ||
} | ||
items = [ | ||
conditions | ||
dxr | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 render to connect to the function locally. | ||
render.crossplane.io/runtime: Development | ||
spec: | ||
package: xpkg.upbound.io/crossplane-contrib/function-kcl:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: example.crossplane.io/v1beta1 | ||
kind: XR | ||
metadata: | ||
name: example | ||
spec: | ||
count: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
run: | ||
crossplane render --verbose xr.yaml composition.yaml functions.yaml -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Example Manifests | ||
|
||
You can run your function locally and test it using `crossplane 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 render --verbose xr.yaml composition.yaml functions.yaml -r --extra-resources extra_resources.yaml | ||
--- | ||
--- | ||
apiVersion: example.crossplane.io/v1beta1 | ||
kind: XR | ||
metadata: | ||
name: example | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2024-01-01T00:00:00Z" | ||
message: 'Unready resources: another-awesome-dev-bucket, my-awesome-dev-bucket' | ||
reason: Creating | ||
status: "False" | ||
type: Ready | ||
--- | ||
apiVersion: example/v1alpha1 | ||
kind: Foo | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: another-awesome-dev-bucket | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: another-awesome-dev-bucket | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
--- | ||
apiVersion: example/v1alpha1 | ||
kind: Foo | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: my-awesome-dev-bucket | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: my-awesome-dev-bucket | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: Composition | ||
metadata: | ||
name: function-template-go | ||
spec: | ||
compositeTypeRef: | ||
apiVersion: example.crossplane.io/v1beta1 | ||
kind: XR | ||
mode: Pipeline | ||
pipeline: | ||
- step: normal | ||
functionRef: | ||
name: kcl-function | ||
input: | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLInput | ||
metadata: | ||
annotations: | ||
"krm.kcl.dev/default_ready": "True" | ||
name: basic | ||
spec: | ||
source: | | ||
oxr = option("params").oxr | ||
dxr = { | ||
**oxr | ||
} | ||
events = { | ||
apiVersion: "meta.krm.kcl.dev/v1alpha1" | ||
kind: "Events" | ||
events = [ | ||
{ | ||
target: "CompositeAndClaim" | ||
event = { | ||
type: "Warning" | ||
reason: "ResourceLimitExceeded" | ||
message: "The resource limit has been exceeded" | ||
} | ||
} | ||
] | ||
} | ||
items = [ | ||
events | ||
dxr | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 render to connect to the function locally. | ||
render.crossplane.io/runtime: Development | ||
spec: | ||
package: xpkg.upbound.io/crossplane-contrib/function-kcl:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: example.crossplane.io/v1beta1 | ||
kind: XR | ||
metadata: | ||
name: example | ||
spec: | ||
count: 1 |
Oops, something went wrong.