Skip to content

Commit 91c9ae8

Browse files
docs: add examples for Secret use-case with base64 decoding (#846)
* docs: add examples for Secret use-case with base64 decoding * Update website/docs/examples/basic/optionals.md Co-authored-by: Jakob Möller <[email protected]> * Update website/docs/examples/basic/optionals.md Co-authored-by: Jakob Möller <[email protected]> * docs: enhance examples for optional values and external references * docs: remove optional namespace field from Secret example * revert :D --------- Co-authored-by: Jakob Möller <[email protected]>
1 parent d997251 commit 91c9ae8

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

website/docs/examples/basic/optionals.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ sidebar_position: 104
44

55
# Optional Values & External References
66

7+
## Config Map
8+
9+
This example shows how to reference an existing ConfigMap and use the optional accessor `?` to safely extract values.
710

811
```yaml title="config-map.yaml"
912
apiVersion: v1
@@ -57,4 +60,46 @@ spec:
5760
env:
5861
- name: MY_VALUE
5962
value: ${input.data.?ECHO_VALUE}
60-
```
63+
```
64+
65+
## Secret
66+
67+
This example demonstrates referencing an existing Secret and transforming its base64-encoded data using CEL expressions with the optional accessor and base64 decoding functions.
68+
69+
```yaml title="secret.yaml"
70+
apiVersion: v1
71+
kind: Secret
72+
metadata:
73+
name: test
74+
stringData:
75+
uri: api.test.com
76+
```
77+
78+
```yaml title="secret-transformation-rg.yaml"
79+
apiVersion: kro.run/v1alpha1
80+
kind: ResourceGraphDefinition
81+
metadata:
82+
name: secret-transformation
83+
spec:
84+
schema:
85+
apiVersion: v1alpha1
86+
kind: test
87+
spec:
88+
name: string
89+
resources:
90+
- id: test
91+
externalRef:
92+
apiVersion: v1
93+
kind: Secret
94+
metadata:
95+
name: test
96+
namespace: ""
97+
- id: secret
98+
template:
99+
apiVersion: v1
100+
kind: Secret
101+
metadata:
102+
name: "${schema.spec.name}"
103+
stringData:
104+
token: "${ string(base64.decode(string(test.data.uri))) }/oauth/token"
105+
```

0 commit comments

Comments
 (0)