generated from crossplane/function-template-go
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathcomposition.yaml
More file actions
47 lines (42 loc) · 1.84 KB
/
composition.yaml
File metadata and controls
47 lines (42 loc) · 1.84 KB
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
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: example-function-get-resource-condition
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1beta1
kind: XR
mode: Pipeline
pipeline:
- step: render-templates
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
---
apiVersion: {{ .observed.composite.resource.apiVersion }}
kind: {{ .observed.composite.resource.kind }}
status:
# retrieve condition of XR
compositeCondition:
{{ getResourceCondition "Ready" .observed.composite | toYaml | nindent 4 }}
# retrieve non existing condition of a resource just returns an Unknown condition
compositeConditionNotFound:
{{ getResourceCondition "Other" .observed.composite | toYaml | nindent 4 }}
# You can also retrieve conditions of composed resources the same way
composedCondition:
{{ getResourceCondition "Ready" .observed.resources.project | toYaml | nindent 4 }}
# Use a getResourceCondition to render conditional blocks in templates
{{ if eq (getResourceCondition "Ready" .observed.resources.project).Status "True" }}
projectId: {{ .observed.resources.project.resource.status.atProvider.id | quote }}
{{ end }}
# Alternative syntax using pipelines
pipeline:
{{ .observed.resources.project | getResourceCondition "Ready" | toYaml | nindent 4 }}
# Non object
nonResource:
{{ .observed.whatever | getResourceCondition "Ready" | toYaml | nindent 4 }}