Browse Source

docs: document the behavior of advanced templating for custom targets (#5810)

Co-authored-by: Gustavo Fernandes de Carvalho <17139678+gusfcarvalho@users.noreply.github.com>
Gergely Bräutigam 3 months ago
parent
commit
a1503adadb
1 changed files with 21 additions and 0 deletions
  1. 21 0
      docs/guides/targeting-custom-resources.md

+ 21 - 0
docs/guides/targeting-custom-resources.md

@@ -56,6 +56,27 @@ When working with custom resources that have complex structures, you can use `ta
 
 The `target` field accepts dot-notation paths like `spec.database` or `spec.logging` to place the rendered template output at specific locations in the resource structure. When `target` is not specified it defaults to `Data` for backward compatibility with Secrets.
 
+!!! note "Using `property` when templating `data`"
+    The return of `data:` isn't an object on the template scope. If templated as a `string` it will fail in finding the right key. Therefore, something like this:
+    ```yaml
+      data:
+        - secretKey: url
+          remoteRef:
+            key: slack-alerts/myalert-dev
+    ```
+    templated as a literal:
+    ```yaml
+    {% raw %}
+    template:
+      engineVersion: v2
+      templateFrom:
+        - literal: |
+            api_url: {{ .url }}
+          target: spec.slack
+    {% endraw %}
+    ```
+    will not work. A property like `property: url` MUST be defined.
+
 ## Drift Detection
 
 The operator automatically detects and corrects manual changes to managed custom resources. If you modify a ConfigMap or custom resource that is managed by an ExternalSecret, the operator will restore it to the desired state immediately.