Skip to content

Commit

Permalink
Document ytt overlay/insert's via kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
mamachanko committed Sep 16, 2022
1 parent af502c4 commit 083c660
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion site/content/ytt/docs/develop/lang-ref-ytt-overlay.md
Expand Up @@ -403,7 +403,7 @@ See also:

### @overlay/insert

Inserts "right" node before/after the matched "left" node.
Inserts "right" node before/after the matched "left" node. The inserted node is either the "right" node or that provided by a function.

**Valid on:** Document, Array Item.

Expand All @@ -412,6 +412,28 @@ Inserts "right" node before/after the matched "left" node.
```
- **`before=`**`Bool` whether to insert the "right" node immediately in front of the matched "left" node.
- **`after=`**`Bool` whether to insert the "right" node immediately following the matched "left" node.
- **`via=`**`Function(left, right): (any)` _(optional)_ determines the value to substitute in. If omitted, the value is `right`.
- `left` ([`yamlfragment`](lang-ref-yaml-fragment.md) or scalar) — the matched node's value
- `right` ([`yamlfragment`](lang-ref-yaml-fragment.md) or scalar) — the value of the annotated node

**Examples:**

_Example 1: Add to each Namespace_

Add a `ConfigMap` into each `Namespace`:
```yaml
#@ def configMap(namespace):
apiVersion: v1
kind: ConfigMap
metadata:
name: insert
namespace: #@ namespace.metadata.name
#@ end

#@overlay/match overlay.subset({"kind": "Namespace"})
#@overlay/insert after=True, via=lambda namespace, _: configMap(namespace)
---
```

### @overlay/append

Expand Down

0 comments on commit 083c660

Please sign in to comment.