Skip to content

Commit 21623e5

Browse files
committed
chore(examples): cleanup and reformat
* reformat composition with yaml-language-server * remove redundant metadata.name from KCLInput * align compositions names Signed-off-by: Ievgenii Shepeliuk <eshepelyuk@gmail.com>
1 parent 3ee34d1 commit 21623e5

File tree

34 files changed

+1037
-1107
lines changed

34 files changed

+1037
-1107
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ env:
3131
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
3232

3333
# The package to push, without a version tag. The default matches GitHub. For
34-
# example xpkg.upbound.io/crossplane/function-template-go.
34+
# example xpkg.upbound.io/crossplane/function-kcl.
3535
XPKG: xpkg.upbound.io/${{ github.repository}}
3636
CROSSPLANE_REGORG: ghcr.io/${{ github.repository}} # xpkg.crossplane.io/crossplane-contrib
3737

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
11
apiVersion: apiextensions.crossplane.io/v1
22
kind: Composition
33
metadata:
4-
name: function-template-go
4+
name: kcl-function
55
spec:
66
compositeTypeRef:
77
apiVersion: example.crossplane.io/v1beta1
88
kind: XR
99
mode: Pipeline
1010
pipeline:
11-
- step: normal
12-
functionRef:
13-
name: kcl-function
14-
input:
15-
apiVersion: krm.kcl.dev/v1alpha1
16-
kind: KCLInput
17-
metadata:
18-
annotations:
19-
"krm.kcl.dev/default_ready": "True"
20-
name: basic
21-
spec:
22-
source: |
23-
oxr = option("params").oxr
24-
25-
dxr = {
26-
**oxr
27-
}
28-
29-
conditions = {
30-
apiVersion: "meta.krm.kcl.dev/v1alpha1"
31-
kind: "Conditions"
32-
conditions = [
33-
{
34-
target: "CompositeAndClaim"
35-
force: False
36-
condition = {
37-
type: "DatabaseReady"
38-
status: "False"
39-
reason: "FailedToCreate"
40-
message: "Encountered an error creating the database"
11+
- step: normal
12+
functionRef:
13+
name: kcl-function
14+
input:
15+
apiVersion: krm.kcl.dev/v1alpha1
16+
kind: KCLInput
17+
metadata:
18+
annotations:
19+
"krm.kcl.dev/default_ready": "True"
20+
spec:
21+
source: |
22+
oxr = option("params").oxr
23+
24+
dxr = {
25+
**oxr
26+
}
27+
28+
conditions = {
29+
apiVersion: "meta.krm.kcl.dev/v1alpha1"
30+
kind: "Conditions"
31+
conditions = [
32+
{
33+
target: "CompositeAndClaim"
34+
force: False
35+
condition = {
36+
type: "DatabaseReady"
37+
status: "False"
38+
reason: "FailedToCreate"
39+
message: "Encountered an error creating the database"
40+
}
4141
}
42-
}
43-
]
44-
45-
}
46-
items = [
47-
conditions
48-
dxr
49-
]
42+
]
43+
44+
}
45+
items = [
46+
conditions
47+
dxr
48+
]
Lines changed: 78 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,89 @@
11
apiVersion: apiextensions.crossplane.io/v1
22
kind: Composition
33
metadata:
4-
name: function-template-go
4+
name: kcl-function
55
spec:
66
compositeTypeRef:
77
apiVersion: example.crossplane.io/v1beta1
88
kind: XR
99
mode: Pipeline
1010
pipeline:
11-
- step: normal
12-
functionRef:
13-
name: kcl-function
14-
input:
15-
apiVersion: krm.kcl.dev/v1alpha1
16-
kind: KCLInput
17-
metadata:
18-
annotations:
19-
"krm.kcl.dev/default_ready": "True"
20-
name: basic
21-
spec:
22-
source: |
23-
import base64
11+
- step: normal
12+
functionRef:
13+
name: kcl-function
14+
input:
15+
apiVersion: krm.kcl.dev/v1alpha1
16+
kind: KCLInput
17+
metadata:
18+
annotations:
19+
"krm.kcl.dev/default_ready": "True"
20+
spec:
21+
source: |
22+
import base64
2423
25-
oxr = option("params").oxr
26-
count = oxr.spec.count or 1
27-
ocds = option("params").ocds
28-
dxr = {
29-
**option("params").dxr
30-
status.dummy = "cool-status"
31-
}
32-
details = {
33-
apiVersion: "meta.krm.kcl.dev/v1alpha1"
34-
kind: "CompositeConnectionDetails"
35-
if "sample-access-key-0" in ocds:
36-
data: {
37-
username = ocds["sample-access-key-0"].ConnectionDetails.username
38-
password = ocds["sample-access-key-0"].ConnectionDetails.password
39-
url = base64.encode("http://www.example.com")
40-
}
41-
else:
42-
data: {}
43-
}
44-
items = sum([[{
45-
apiVersion: "iam.aws.upbound.io/v1beta1"
46-
kind: "User"
47-
metadata.name = "test-user-{}".format(i)
48-
metadata.labels: {
49-
"testing.upbound.io/example-name" = "test-user-{}".format(i)
50-
if "test-user-{}".format(i) in ocds:
51-
dummy = ocds["test-user-{}".format(i)].Resource.metadata.labels.dummy
52-
else:
53-
dummy = "foo"
54-
}
55-
metadata.annotations: {
56-
"krm.kcl.dev/ready": "False"
57-
}
58-
spec.forProvider: {}
59-
}, {
60-
apiVersion: "iam.aws.upbound.io/v1beta1"
61-
kind: "AccessKey"
62-
metadata.name = "sample-access-key-{}".format(i)
63-
metadata.annotations: {
64-
"krm.kcl.dev/ready": "True"
65-
}
66-
spec.forProvider.userSelector.matchLabels: {
67-
"testing.upbound.io/example-name" = "test-user-{}".format(i)
68-
}
69-
spec.writeConnectionSecretToRef: {
70-
name: "sample-access-key-secret-{}".format(i)
71-
namespace: "crossplane-system"
72-
}
73-
}] for i in range(count)], []) + [
74-
details
75-
dxr
76-
]
24+
oxr = option("params").oxr
25+
count = oxr.spec.count or 1
26+
ocds = option("params").ocds
27+
dxr = {
28+
**option("params").dxr
29+
status.dummy = "cool-status"
30+
}
31+
details = {
32+
apiVersion: "meta.krm.kcl.dev/v1alpha1"
33+
kind: "CompositeConnectionDetails"
34+
if "sample-access-key-0" in ocds:
35+
data: {
36+
username = ocds["sample-access-key-0"].ConnectionDetails.username
37+
password = ocds["sample-access-key-0"].ConnectionDetails.password
38+
url = base64.encode("http://www.example.com")
39+
}
40+
else:
41+
data: {}
42+
}
43+
items = sum([[{
44+
apiVersion: "iam.aws.upbound.io/v1beta1"
45+
kind: "User"
46+
metadata.name = "test-user-{}".format(i)
47+
metadata.labels: {
48+
"testing.upbound.io/example-name" = "test-user-{}".format(i)
49+
if "test-user-{}".format(i) in ocds:
50+
dummy = ocds["test-user-{}".format(i)].Resource.metadata.labels.dummy
51+
else:
52+
dummy = "foo"
53+
}
54+
metadata.annotations: {
55+
"krm.kcl.dev/ready": "False"
56+
}
57+
spec.forProvider: {}
58+
}, {
59+
apiVersion: "iam.aws.upbound.io/v1beta1"
60+
kind: "AccessKey"
61+
metadata.name = "sample-access-key-{}".format(i)
62+
metadata.annotations: {
63+
"krm.kcl.dev/ready": "True"
64+
}
65+
spec.forProvider.userSelector.matchLabels: {
66+
"testing.upbound.io/example-name" = "test-user-{}".format(i)
67+
}
68+
spec.writeConnectionSecretToRef: {
69+
name: "sample-access-key-secret-{}".format(i)
70+
namespace: "crossplane-system"
71+
}
72+
}] for i in range(count)], []) + [
73+
details
74+
dxr
75+
]
7776
78-
# Just for test
79-
- step: normal1
80-
functionRef:
81-
name: kcl-function
82-
input:
83-
apiVersion: krm.kcl.dev/v1alpha1
84-
kind: KCLInput
85-
metadata:
86-
name: show-dcds
87-
spec:
88-
source: |
89-
{
90-
metadata.name = "dcds"
91-
dcds: option("params").dcds
92-
}
77+
# Just for test
78+
- step: normal1
79+
functionRef:
80+
name: kcl-function
81+
input:
82+
apiVersion: krm.kcl.dev/v1alpha1
83+
kind: KCLInput
84+
spec:
85+
source: |
86+
{
87+
metadata.name = "dcds"
88+
dcds: option("params").dcds
89+
}
Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
11
apiVersion: apiextensions.crossplane.io/v1
22
kind: Composition
33
metadata:
4-
name: function-template-go
4+
name: kcl-function
55
spec:
66
compositeTypeRef:
77
apiVersion: example.crossplane.io/v1beta1
88
kind: XR
99
mode: Pipeline
1010
pipeline:
11-
- step: normal
12-
functionRef:
13-
name: kcl-function
14-
input:
15-
apiVersion: krm.kcl.dev/v1alpha1
16-
kind: KCLInput
17-
metadata:
18-
annotations:
19-
"krm.kcl.dev/default_ready": "True"
20-
name: basic
21-
spec:
22-
source: |
23-
oxr = option("params").oxr
11+
- step: normal
12+
functionRef:
13+
name: kcl-function
14+
input:
15+
apiVersion: krm.kcl.dev/v1alpha1
16+
kind: KCLInput
17+
metadata:
18+
annotations:
19+
"krm.kcl.dev/default_ready": "True"
20+
spec:
21+
source: |
22+
oxr = option("params").oxr
2423
25-
dxr = {
26-
**oxr
27-
}
24+
dxr = {
25+
**oxr
26+
}
2827
29-
context = {
30-
apiVersion: "meta.krm.kcl.dev/v1alpha1"
31-
kind: "Context"
32-
data = {
33-
contextField = "contextValue"
34-
moreComplexField = {
35-
test: "field"
28+
context = {
29+
apiVersion: "meta.krm.kcl.dev/v1alpha1"
30+
kind: "Context"
31+
data = {
32+
contextField = "contextValue"
33+
moreComplexField = {
34+
test: "field"
35+
}
3636
}
37-
}
38-
}
39-
items = [
40-
context
41-
dxr
42-
]
37+
}
38+
items = [
39+
context
40+
dxr
41+
]

0 commit comments

Comments
 (0)