Skip to content

Commit

Permalink
Merge pull request #9 from ezgidemirel/add-cm-example
Browse files Browse the repository at this point in the history
Add 'templates.tmpl' file and update filesystem example README
  • Loading branch information
negz authored Nov 2, 2023
2 parents e7155ca + 9068aa7 commit 7bdd034
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
11 changes: 10 additions & 1 deletion example/filesystem/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# The `FileSystem` source

You can't run the example in this directory using `crossplane beta render`
because it loads templates from a ConfigMap. See `functions.yaml` for details.
because it loads templates from a ConfigMap.

You can create a ConfigMap with the templates using the following command:

```shell
kubectl create configmap templates --from-file=templates.tmpl -n crossplane-system
```

This ConfigMap will be mounted to the function pod and the templates will be
available in the `/templates` directory. Please see `functions.yaml` for details.
2 changes: 1 addition & 1 deletion example/filesystem/functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kind: Function
metadata:
name: function-go-templating
spec:
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.0.0-20231101231317-cdb49945da4e
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.0.0-20231102045703-5dbf5b2adbc4
runtimeConfigRef:
name: mount-templates
---
Expand Down
47 changes: 47 additions & 0 deletions example/filesystem/templates.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- range $i := until ( .observed.composite.resource.spec.count | int ) }}
---
apiVersion: iam.aws.upbound.io/v1beta1
kind: User
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: test-user-{{ $i }}
labels:
testing.upbound.io/example-name: test-user-{{ $i }}
{{ if eq $.observed.resources nil }}
dummy: {{ randomChoice "foo" "bar" "baz" }}
{{ else }}
dummy: {{ ( index $.observed.resources ( print "test-user-" $i ) ).resource.metadata.labels.dummy }}
{{ end }}
spec:
forProvider: {}
---
apiVersion: iam.aws.upbound.io/v1beta1
kind: AccessKey
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: sample-access-key-{{ $i }}
spec:
forProvider:
userSelector:
matchLabels:
testing.upbound.io/example-name: test-user-{{ $i }}
writeConnectionSecretToRef:
name: sample-access-key-secret-{{ $i }}
namespace: crossplane-system
{{- end }}
---
apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1
kind: CompositeConnectionDetails
{{ if eq $.observed.resources nil }}
data: {}
{{ else }}
data:
username: {{ ( index $.observed.resources "sample-access-key-0" ).connectionDetails.username }}
password: {{ ( index $.observed.resources "sample-access-key-0" ).connectionDetails.password }}
url: {{ "http://www.example.com" | b64enc }}
{{ end }}
---
apiVersion: aws.platformref.upbound.io/v1alpha1
kind: XUser
status:
dummy: cool-status

0 comments on commit 7bdd034

Please sign in to comment.