feat(yaml-updater): add ability to append to mapping keys#5394
Open
mihuross wants to merge 1 commit intoakuity:mainfrom
Open
feat(yaml-updater): add ability to append to mapping keys#5394mihuross wants to merge 1 commit intoakuity:mainfrom
mihuross wants to merge 1 commit intoakuity:mainfrom
Conversation
If the path points to non existing key in mapping node and would otherwise be a terminal one, add ability to append that key with new value. Signed-off-by: Michal Humpula <michal.humpula@rossum.ai>
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the path points to non existing key in mapping node and would otherwise be a terminal one, add ability to append that key with new value.
I was trying to find a usable implementation somewhere else, but ultimately failed to do so :(
This is a best approach I could come up with, that is minimal and supports adding a new key to mapping node while trying to preserve indentations. This can still screw up formatting rules though (e.g. if formater requires specific key ordering in mapping). For the similar reason, append to empty mapping node is not possible, since it would have to guess what is the correct indentation step.
Adding ability to append to lists might work in similar way.
Related to #5299
As described in the issue, I think this is still rather an edge case to solve (although very useful for me), so adding extra code just for this, might not be a good trade of.