forked from crossplane-contrib/function-kcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
composition.yaml
92 lines (90 loc) · 2.81 KB
/
composition.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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"
}
metadata.annotations: {
"krm.kcl.dev/ready": "False"
}
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
}