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 #61 from Peefy/feat-default-target-with-connection…
…-details feat: impl default target with connection details in the function-kcl v0.4.0
- Loading branch information
Showing
20 changed files
with
646 additions
and
28 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
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 beta render 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,113 @@ | ||
# 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: example.crossplane.io/v1beta1 | ||
kind: XR | ||
metadata: | ||
name: example | ||
status: | ||
dummy: cool-status | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: AccessKey | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: sample-access-key-1 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: sample-access-key-1 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: | ||
userSelector: | ||
matchLabels: | ||
testing.upbound.io/example-name: test-user-1 | ||
writeConnectionSecretToRef: | ||
name: sample-access-key-secret-1 | ||
namespace: crossplane-system | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: User | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: test-user-0 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
dummy: foo | ||
testing.upbound.io/example-name: test-user-0 | ||
name: test-user-0 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: {} | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: AccessKey | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: sample-access-key-0 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: sample-access-key-0 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: | ||
userSelector: | ||
matchLabels: | ||
testing.upbound.io/example-name: test-user-0 | ||
writeConnectionSecretToRef: | ||
name: sample-access-key-secret-0 | ||
namespace: crossplane-system | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: User | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: test-user-1 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
dummy: foo | ||
testing.upbound.io/example-name: test-user-1 | ||
name: test-user-1 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: {} | ||
``` |
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,89 @@ | ||
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: normal | ||
functionRef: | ||
name: kcl-function | ||
input: | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLRun | ||
metadata: | ||
annotations: | ||
"krm.kcl.dev/default_ready": "True" | ||
name: basic | ||
spec: | ||
source: | | ||
import base64 | ||
oxr = option("params").oxr | ||
count = oxr.spec.count or 1 | ||
ocds = option("params").ocds | ||
dxr = { | ||
**oxr | ||
status.dummy = "cool-status" | ||
} | ||
details = { | ||
apiVersion: "meta.krm.kcl.dev/v1alpha1" | ||
kind: "CompositeConnectionDetails" | ||
if "sample-access-key-0" in ocds: | ||
data: { | ||
username = ocds["sample-access-key-0"].ConnectionDetails.username | ||
password = ocds["sample-access-key-0"].ConnectionDetails.password | ||
url = base64.encode("http://www.example.com") | ||
} | ||
else: | ||
data: {} | ||
} | ||
items = sum([[{ | ||
apiVersion: "iam.aws.upbound.io/v1beta1" | ||
kind: "User" | ||
metadata.name = "test-user-{}".format(i) | ||
metadata.labels: { | ||
"testing.upbound.io/example-name" = "test-user-{}".format(i) | ||
if "test-user-{}".format(i) in ocds: | ||
dummy = ocds["test-user-{}".format(i)].Resource.metadata.labels.dummy | ||
else: | ||
dummy = "foo" | ||
} | ||
spec.forProvider: {} | ||
}, { | ||
apiVersion: "iam.aws.upbound.io/v1beta1" | ||
kind: "AccessKey" | ||
metadata.name = "sample-access-key-{}".format(i) | ||
metadata.annotations: { | ||
"krm.kcl.dev/ready": "True" | ||
} | ||
spec.forProvider.userSelector.matchLabels: { | ||
"testing.upbound.io/example-name" = "test-user-{}".format(i) | ||
} | ||
spec.writeConnectionSecretToRef: { | ||
name: "sample-access-key-secret-{}".format(i) | ||
namespace: "crossplane-system" | ||
} | ||
}] for i in range(count)], []) + [ | ||
details | ||
dxr | ||
] | ||
# Just for test | ||
- step: normal1 | ||
functionRef: | ||
name: kcl-function | ||
input: | ||
apiVersion: krm.kcl.dev/v1alpha1 | ||
kind: KCLRun | ||
metadata: | ||
name: show-dcds | ||
spec: | ||
source: | | ||
{ | ||
metadata.name = "dcds" | ||
dcds: option("params").dcds | ||
} |
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 beta 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 beta render 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,113 @@ | ||
# 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: example.crossplane.io/v1beta1 | ||
kind: XR | ||
metadata: | ||
name: example | ||
status: | ||
dummy: cool-status | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: AccessKey | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: sample-access-key-1 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: sample-access-key-1 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: | ||
userSelector: | ||
matchLabels: | ||
testing.upbound.io/example-name: test-user-1 | ||
writeConnectionSecretToRef: | ||
name: sample-access-key-secret-1 | ||
namespace: crossplane-system | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: User | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: test-user-0 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
dummy: foo | ||
testing.upbound.io/example-name: test-user-0 | ||
name: test-user-0 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: {} | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: AccessKey | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: sample-access-key-0 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
name: sample-access-key-0 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: | ||
userSelector: | ||
matchLabels: | ||
testing.upbound.io/example-name: test-user-0 | ||
writeConnectionSecretToRef: | ||
name: sample-access-key-secret-0 | ||
namespace: crossplane-system | ||
--- | ||
apiVersion: iam.aws.upbound.io/v1beta1 | ||
kind: User | ||
metadata: | ||
annotations: | ||
crossplane.io/composition-resource-name: test-user-1 | ||
generateName: example- | ||
labels: | ||
crossplane.io/composite: example | ||
dummy: foo | ||
testing.upbound.io/example-name: test-user-1 | ||
name: test-user-1 | ||
ownerReferences: | ||
- apiVersion: example.crossplane.io/v1beta1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: XR | ||
name: example | ||
uid: "" | ||
spec: | ||
forProvider: {} | ||
``` |
Oops, something went wrong.