-
Notifications
You must be signed in to change notification settings - Fork 163
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
feat: make yaml-update syntax the same as json-update syntax #3156
Conversation
Signed-off-by: Kent Rancourt <[email protected]>
Signed-off-by: Kent Rancourt <[email protected]>
✅ Deploy Preview for docs-kargo-io ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3156 +/- ##
==========================================
+ Coverage 51.27% 51.37% +0.09%
==========================================
Files 285 285
Lines 25706 25763 +57
==========================================
+ Hits 13182 13236 +54
- Misses 11824 11825 +1
- Partials 700 702 +2 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Kent Rancourt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
…3156) Signed-off-by: Kent Rancourt <[email protected]>
…3156) Signed-off-by: Kent Rancourt <[email protected]>
This complements #3151.
#3151 uses tidwall/sjson for modifying JSON documents whilst preserving their existing formatting.
The keys/paths supported by that library use simple dot-separated notation. Dots can be escaped. Colons are used as a hint that a numeric-looking key part should be treated as a key in an object and not as an index in a sequence. Colons also can be escaped.
Examples:
-1 can be used as an index to indicate a desire to append to a sequence.
This is slightly inconsistent with the syntax supported by our yaml-update step.
These slightly different syntaxes were inevitably going to lead to confusion.
This PR updates the internal
yaml
library we use for editing YAML whilst preserving comments and formatting choices, and by extension the yaml-update step, to use the same syntax as tidwall/sjson and the new json-update step.There are no breaking changes in this PR. The legacy syntax still works.
Since these changes open the possibility of using our internal
yaml
package, and by extension the yaml-update step, to append to a sequence (which it couldn't do before), the notion of using a map of key/value pairs as input to update operations is invalidated. If we can append to a sequence, order matters now...So to enable all of the above, this PR also contains a small bit of refactoring to transition away from using maps as input to YAML update operations and toward using arrays of yaml.Update structs.
cc @fykaa