Skip to content

Commit 5bfd8e6

Browse files
committed
update the compostion example
Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com
1 parent f45c4f5 commit 5bfd8e6

1 file changed

Lines changed: 122 additions & 122 deletions

File tree

docs/content/usage/integrations/crossplane.md

Lines changed: 122 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ EOF
111111
```
112112

113113
```yaml
114-
kubectl apply -f - <<EOF
114+
kubectl apply -f - <<'EOF'
115115
apiVersion: apiextensions.crossplane.io/v1
116116
kind: Composition
117117
metadata:
@@ -122,128 +122,128 @@ spec:
122122
kind: MySQLDatabase
123123
mode: Pipeline
124124
pipeline:
125-
- step: create-mysql-resources
126-
functionRef:
127-
name: function-go-templating
128-
input:
129-
apiVersion: gotemplating.fn.crossplane.io/v1beta1
130-
kind: GoTemplate
131-
source: Inline
132-
inline:
133-
template: |
134-
{{ $objName := .observed.composite.resource.metadata.name }}
135-
{{ $dbName := .observed.composite.resource.spec.name }}
136-
{{ $objNamespace := .observed.composite.resource.metadata.namespace }}
137-
{{ $userName := printf "%s-user" $dbName }}
138-
{{ $secretName := printf "%s-secret" $dbName }}
139-
{{ $credentials := printf "%s-credentials" $objName }}
140-
---
141-
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
142-
kind: Database
143-
metadata:
144-
annotations:
145-
gotemplating.fn.crossplane.io/composition-resource-name: database
146-
{{ if eq (.observed.resources.database | getResourceCondition "Synced").Status "True" }}
147-
gotemplating.fn.crossplane.io/ready: "True"
148-
{{ end }}
149-
name: {{ $dbName }}
150-
namespace: default
151-
spec:
152-
forProvider: {}
153-
providerConfigRef:
154-
kind: ProviderConfig
155-
name: mysql-cfg
156-
---
157-
apiVersion: v1
158-
kind: Secret
159-
metadata:
160-
annotations:
161-
gotemplating.fn.crossplane.io/composition-resource-name: secret-exposed
162-
gotemplating.fn.crossplane.io/ready: "True"
163-
labels:
164-
kube-bind.io/selector: consumer-database
165-
namespace: default
166-
name: {{ $credentials }}
167-
{{ if eq $.observed.resources nil }}
168-
stringData: {}
169-
{{ else }}
170-
stringData:
171-
username: {{ ( index $.observed.resources "user" ).connectionDetails.username }}
172-
password: {{ ( index $.observed.resources "user" ).connectionDetails.password }}
173-
port: {{ ( index $.observed.resources "user" ).connectionDetails.port }}
174-
endpoint: {{ ( index $.observed.resources "user" ).connectionDetails.endpoint }}
175-
{{ end }}
176-
---
177-
apiVersion: v1
178-
kind: Secret
179-
metadata:
180-
annotations:
181-
gotemplating.fn.crossplane.io/composition-resource-name: secret
182-
gotemplating.fn.crossplane.io/ready: "True"
183-
namespace: default
184-
name: {{ $secretName }}
185-
data:
186-
password: {{ randAlphaNum 16 | b64enc }}
187-
---
188-
# Hardcoded demo Secret used by ProviderConfig (in default namespace)
189-
apiVersion: v1
190-
kind: Secret
191-
metadata:
192-
annotations:
193-
gotemplating.fn.crossplane.io/composition-resource-name: provider-db-conn
194-
gotemplating.fn.crossplane.io/ready: "True"
195-
namespace: default
196-
name: db-conn
197-
type: Opaque
198-
stringData:
199-
endpoint: mysql.default.svc.cluster.local
200-
port: "3306"
201-
username: root
202-
password: password
203-
---
204-
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
205-
kind: User
206-
metadata:
207-
annotations:
208-
gotemplating.fn.crossplane.io/composition-resource-name: user
209-
{{ if eq (.observed.resources.user | getResourceCondition "Synced").Status "True" }}
210-
gotemplating.fn.crossplane.io/ready: "True"
211-
{{ end }}
212-
name: {{ $userName }}
213-
namespace: default
214-
spec:
215-
forProvider:
216-
passwordSecretRef:
217-
name: {{ $secretName }}
218-
key: password
219-
writeConnectionSecretToRef:
220-
name: {{ printf "%s-connection-secret" $dbName }}
221-
providerConfigRef:
222-
kind: ProviderConfig
223-
name: mysql-cfg
224-
---
225-
apiVersion: mangodb.com/v1
226-
kind: MySQLDatabase
227-
metadata:
228-
name: {{ $objName }}
229-
namespace: default
230-
status:
231-
ready: {{ and (eq (.observed.resources.database | getResourceCondition "Synced").Status "True") (eq (.observed.resources.user | getResourceCondition "Synced").Status "True") }}
232-
connectionSecret: {{ printf "%s-connection-secret" $dbName }}
233-
---
234-
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
235-
kind: ProviderConfig
236-
metadata:
125+
- functionRef:
126+
name: function-go-templating
127+
input:
128+
apiVersion: gotemplating.fn.crossplane.io/v1beta1
129+
inline:
130+
template: |
131+
{{ $objName := .observed.composite.resource.metadata.name }}
132+
{{ $dbName := .observed.composite.resource.spec.name }}
133+
{{ $objNamespace := .observed.composite.resource.metadata.namespace }}
134+
{{ $userName := printf "%s-user" $dbName }}
135+
{{ $secretName := printf "%s-secret" $dbName }}
136+
{{ $credentials := printf "%s-credentials" $objName }}
137+
---
138+
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
139+
kind: Database
140+
metadata:
141+
annotations:
142+
gotemplating.fn.crossplane.io/composition-resource-name: database
143+
{{ if eq (.observed.resources.database | getResourceCondition "Synced").Status "True" }}
144+
gotemplating.fn.crossplane.io/ready: "True"
145+
{{ end }}
146+
name: {{ $dbName }}
147+
namespace: default
148+
spec:
149+
forProvider: {}
150+
providerConfigRef:
151+
kind: ProviderConfig
152+
name: mysql-cfg
153+
---
154+
apiVersion: v1
155+
kind: Secret
156+
metadata:
157+
annotations:
158+
gotemplating.fn.crossplane.io/composition-resource-name: secret-exposed
159+
gotemplating.fn.crossplane.io/ready: "True"
160+
labels:
161+
kube-bind.io/selector: consumer-database
162+
namespace: default
163+
name: {{ $credentials }}
164+
{{ if eq $.observed.resources nil }}
165+
stringData: {}
166+
{{ else }}
167+
stringData:
168+
username: {{ ( index $.observed.resources "user" ).connectionDetails.username }}
169+
password: {{ ( index $.observed.resources "user" ).connectionDetails.password }}
170+
port: {{ ( index $.observed.resources "user" ).connectionDetails.port }}
171+
endpoint: {{ ( index $.observed.resources "user" ).connectionDetails.endpoint }}
172+
{{ end }}
173+
---
174+
apiVersion: v1
175+
kind: Secret
176+
metadata:
177+
annotations:
178+
gotemplating.fn.crossplane.io/composition-resource-name: secret
179+
gotemplating.fn.crossplane.io/ready: "True"
180+
namespace: default
181+
name: {{ $secretName }}
182+
data:
183+
password: {{ randAlphaNum 16 | b64enc }}
184+
---
185+
# Hardcoded demo Secret used by ProviderConfig (in default namespace)
186+
apiVersion: v1
187+
kind: Secret
188+
metadata:
189+
annotations:
190+
gotemplating.fn.crossplane.io/composition-resource-name: provider-db-conn
191+
gotemplating.fn.crossplane.io/ready: "True"
192+
namespace: default
193+
name: db-conn
194+
type: Opaque
195+
stringData:
196+
endpoint: mysql.default.svc.cluster.local
197+
port: "3306"
198+
username: root
199+
password: password
200+
---
201+
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
202+
kind: User
203+
metadata:
204+
annotations:
205+
gotemplating.fn.crossplane.io/composition-resource-name: user
206+
{{ if eq (.observed.resources.user | getResourceCondition "Synced").Status "True" }}
207+
gotemplating.fn.crossplane.io/ready: "True"
208+
{{ end }}
209+
name: {{ $userName }}
210+
namespace: default
211+
spec:
212+
forProvider:
213+
passwordSecretRef:
214+
name: {{ $secretName }}
215+
key: password
216+
writeConnectionSecretToRef:
217+
name: {{ printf "%s-connection-secret" $dbName }}
218+
providerConfigRef:
219+
kind: ProviderConfig
237220
name: mysql-cfg
238-
annotations:
239-
gotemplating.fn.crossplane.io/composition-resource-name: provider-cfg
240-
gotemplating.fn.crossplane.io/ready: "True"
241-
spec:
242-
credentials:
243-
source: MySQLConnectionSecret
244-
connectionSecretRef:
245-
name: db-conn
246-
tls: preferred
221+
---
222+
apiVersion: mangodb.com/v1
223+
kind: MySQLDatabase
224+
metadata:
225+
name: {{ $objName }}
226+
namespace: default
227+
status:
228+
ready: {{ and (eq (.observed.resources.database | getResourceCondition "Synced").Status "True") (eq (.observed.resources.user | getResourceCondition "Synced").Status "True") }}
229+
connectionSecret: {{ printf "%s-connection-secret" $dbName }}
230+
---
231+
apiVersion: mysql.sql.m.crossplane.io/v1alpha1
232+
kind: ProviderConfig
233+
metadata:
234+
name: mysql-cfg
235+
annotations:
236+
gotemplating.fn.crossplane.io/composition-resource-name: provider-cfg
237+
gotemplating.fn.crossplane.io/ready: "True"
238+
spec:
239+
credentials:
240+
source: MySQLConnectionSecret
241+
connectionSecretRef:
242+
name: db-conn
243+
tls: preferred
244+
kind: GoTemplate
245+
source: Inline
246+
step: create-mysql-resources
247247
EOF
248248
```
249249

0 commit comments

Comments
 (0)