Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlay/replace on a map replaces keys, not only values #946

Open
kralikba opened this issue Mar 4, 2025 · 0 comments
Open

overlay/replace on a map replaces keys, not only values #946

kralikba opened this issue Mar 4, 2025 · 0 comments
Labels
bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance

Comments

@kralikba
Copy link

kralikba commented Mar 4, 2025

What steps did you take:
I tried applying overlay/replace to all child elements' values.

a:
 a1:
   a: 1
   b: 2

#@ load("@ytt:overlay", "overlay")

#@overlay/match by=overlay.all
---
a:
#@overlay/match by=overlay.all, expects="1+"
#@overlay/replace
 _:
   a: 1
   b: 3

What happened:
Not only the values, but their key was replaced as well (to the dummy placeholder value).

a:
  _:
    a: 1
    b: 3

Because of this, matching overlay.all won't really work, as for multiple child items, this will cause a duplicate key error.

What did you expect:
That only the values are replaced

a:
  a1:
    a: 1
    b: 3

Anything else you would like to add:

Using overlay.map_key instead of overlay.all results in the same erroneous behaviour.
overlay/merge behaves as expected (does not replace key) with both matchers.

Environment:

  • ytt version (use ytt --version): 0.51.1
  • OS (e.g. from /etc/os-release): Windows 11 24H2 26100.3194

Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@kralikba kralikba added bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance labels Mar 4, 2025
@carvel-bot carvel-bot added this to Carvel Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance
Projects
Status: No status
Development

No branches or pull requests

1 participant