carvel-dev / carvel-dev/ytt

Support "replacert" in overlays

Open
#335 4 comments 0 reactions 0 assignees View on GitHub
discussion enhancement
Dominant language
Go
Stars
1.9k
Forks
167
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem/challenge you have**

I would like to be able to, in one overlay operation:
- replace a {map item, array item, document} if it exists with my content; _or_
- append my content as a new item in the collection.

Today, I need to do that in two operations:
```
#@overlay/match by=overlay.subset({"kind":"Deployment", "metadata":{"name":"frontend"}})
---
spec:
template:
spec:
containers:
#@overlay/match by=overlay.subset({"name": "webserver"})
-
#@overlay/match missing_ok=True
#@overlay/remove
args:

#@overlay/match by=overlay.subset({"kind":"Deployment", "metadata":{"name":"frontend"}})
---
spec:
template:
spec:
containers:
#@overlay/match by=overlay.subset({"name": "webserver"})
-
#@overlay/match missing_ok=True
args: #@ data.values.deployment.args
```

**Describe the solution you'd like**

I'd rather `@overlay/replace` have an "replacert" behavior.

If that were the case, this would accomplish the same thing as above with just one overlay, greatly simplifying it:
```
#@overlay/match by=overlay.subset({"kind":"Deployment", "metadata":{"name":"frontend"}})
---
spec:
template:
spec:
containers:
#@overlay/match by=overlay.subset({"name": "webserver"})
-
#@overlay/match missing_ok=True
#@overlay/replace
args:
```

**Anything else you would like to add:**
The verbosity of doing this in multiple operations grows noticeably as the number of items being overlay'ed within the map increases

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.