fix: op patching to not add elements if key already exists#2206
Merged
FabianKramm merged 2 commits intomasterfrom Aug 9, 2022
Merged
fix: op patching to not add elements if key already exists#2206FabianKramm merged 2 commits intomasterfrom
FabianKramm merged 2 commits intomasterfrom
Conversation
✅ Deploy Preview for devspace-docs canceled.
|
FabianKramm
requested changes
Aug 8, 2022
Collaborator
FabianKramm
left a comment
There was a problem hiding this comment.
@carlmontanari thanks for the PR! Please take a look at my comments below
FabianKramm
approved these changes
Aug 9, 2022
Collaborator
FabianKramm
left a comment
There was a problem hiding this comment.
@carlmontanari thanks! LGTM!
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.
What issue type does this pull request address? (keep at least one, remove the others)
/kind bugfix
/kind test
What does this pull request do? Which issues does it resolve? (use
resolves #<issue_number>if possible)N/A
Please provide a short message that should be published in the DevSpace release notes
Fixed an issue where DevSpace add patch operations on existing keys breaks patching.
What else do we need to know?
This fixes an issue where adding an already existing key to a map would basically append the value in your patch to the key. Unfortunately this would basically shift the yaml around so now the previous value would be the key on the next line. Example:
The above output is an example where there was a context set to "veryimportantpath", and an add op setting the context to "../..". This would obviously cause some errors. Moreover subsequent operations may try to reference the key "dockerfile" which is actually no longer a key in the document, causing an exception like
remove operation does not apply: doc is missing path: images.agent.dockerfile.The
Performfunction got a little more complicated than I'd like to account for not breaking the ability to add elements into existing arrays.