Browse Source

Docs: Add details on how to use FilterPEM function (#2893)

* Docs - add note clarifying how to use filterpem for future readers

Signed-off-by: arnoldrw <arnold.rw@pg.com>

* Update docs/guides/templating.md

Co-authored-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
Signed-off-by: Ryan Arnold <51235300+arnoldrw@users.noreply.github.com>

---------

Signed-off-by: arnoldrw <arnold.rw@pg.com>
Signed-off-by: Ryan Arnold <51235300+arnoldrw@users.noreply.github.com>
Co-authored-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
Ryan Arnold 2 years ago
parent
commit
8fd952c6e7

+ 5 - 1
docs/guides/templating.md

@@ -106,7 +106,11 @@ NtFUGA95RGN9s+pl6XY0YARPHf5O76ErC1OZtDTR5RdyQfcM+94gYZsexsXl0aQO
 
 ```
 
-You can achieve that by using the `filterPEM` function to extract a specific type of PEM block from that secret. If multiple blocks of that type (here: `CERTIFICATE`) exist then all of them are returned in the order they are specified.
+You can achieve that by using the `filterPEM` function to extract a specific type of PEM block from that secret. If multiple blocks of that type (here: `CERTIFICATE`) exist, all of them are returned in the order specified. To extract a specific type of PEM block, pass the type as a string argument to the filterPEM function. Take a look at this example of how to transform a secret which contains a private key and a certificate into the desired format:
+
+```yaml
+{% include 'filterpem-template-v2-external-secret.yaml' %}
+```
 
 ## Helper functions
 

+ 16 - 0
docs/snippets/filterpem-template-v2-external-secret.yaml

@@ -0,0 +1,16 @@
+{% raw %}
+apiVersion: external-secrets.io/v1beta1
+kind: ExternalSecret
+metadata:
+  name: template
+spec:
+  # ...
+  target:
+    template:
+      type: kubernetes.io/tls
+      engineVersion: v2
+      data:
+        tls.crt: "{{ .mysecret | filterPEM "CERTIFICATE" }}"
+        tls.key: "{{ .mysecret | filterPEM "PRIVATE KEY" }}"
+
+{% endraw %}