Skip to content

Commit 7bdd034

Browse files
authored
Merge pull request #9 from ezgidemirel/add-cm-example
Add 'templates.tmpl' file and update filesystem example README
2 parents e7155ca + 9068aa7 commit 7bdd034

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

example/filesystem/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
# The `FileSystem` source
22

33
You can't run the example in this directory using `crossplane beta render`
4-
because it loads templates from a ConfigMap. See `functions.yaml` for details.
4+
because it loads templates from a ConfigMap.
5+
6+
You can create a ConfigMap with the templates using the following command:
7+
8+
```shell
9+
kubectl create configmap templates --from-file=templates.tmpl -n crossplane-system
10+
```
11+
12+
This ConfigMap will be mounted to the function pod and the templates will be
13+
available in the `/templates` directory. Please see `functions.yaml` for details.

example/filesystem/functions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ kind: Function
1111
metadata:
1212
name: function-go-templating
1313
spec:
14-
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.0.0-20231101231317-cdb49945da4e
14+
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.0.0-20231102045703-5dbf5b2adbc4
1515
runtimeConfigRef:
1616
name: mount-templates
1717
---

example/filesystem/templates.tmpl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{- range $i := until ( .observed.composite.resource.spec.count | int ) }}
2+
---
3+
apiVersion: iam.aws.upbound.io/v1beta1
4+
kind: User
5+
metadata:
6+
annotations:
7+
gotemplating.fn.crossplane.io/composition-resource-name: test-user-{{ $i }}
8+
labels:
9+
testing.upbound.io/example-name: test-user-{{ $i }}
10+
{{ if eq $.observed.resources nil }}
11+
dummy: {{ randomChoice "foo" "bar" "baz" }}
12+
{{ else }}
13+
dummy: {{ ( index $.observed.resources ( print "test-user-" $i ) ).resource.metadata.labels.dummy }}
14+
{{ end }}
15+
spec:
16+
forProvider: {}
17+
---
18+
apiVersion: iam.aws.upbound.io/v1beta1
19+
kind: AccessKey
20+
metadata:
21+
annotations:
22+
gotemplating.fn.crossplane.io/composition-resource-name: sample-access-key-{{ $i }}
23+
spec:
24+
forProvider:
25+
userSelector:
26+
matchLabels:
27+
testing.upbound.io/example-name: test-user-{{ $i }}
28+
writeConnectionSecretToRef:
29+
name: sample-access-key-secret-{{ $i }}
30+
namespace: crossplane-system
31+
{{- end }}
32+
---
33+
apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1
34+
kind: CompositeConnectionDetails
35+
{{ if eq $.observed.resources nil }}
36+
data: {}
37+
{{ else }}
38+
data:
39+
username: {{ ( index $.observed.resources "sample-access-key-0" ).connectionDetails.username }}
40+
password: {{ ( index $.observed.resources "sample-access-key-0" ).connectionDetails.password }}
41+
url: {{ "http://www.example.com" | b64enc }}
42+
{{ end }}
43+
---
44+
apiVersion: aws.platformref.upbound.io/v1alpha1
45+
kind: XUser
46+
status:
47+
dummy: cool-status

0 commit comments

Comments
 (0)