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

json-update step #2961

Closed
jessesuen opened this issue Nov 19, 2024 · 1 comment · Fixed by #3151
Closed

json-update step #2961

jessesuen opened this issue Nov 19, 2024 · 1 comment · Fixed by #3151

Comments

@jessesuen
Copy link
Member

Proposed Feature

We just introduced the yaml-update step, which is a great improvement over helm-update-image. Now we should add an equivalent json-update step to deal with json files.

Motivation

This would enable users who use other config management tools like .jsonnet or grafana tanka. Somone using jsonnet could patch an image tag to a .json. Technically they could even patch a .jsonnet file, as long as that file was pure json and did not use any jsonnet syntax.

Suggested Implementation

Step syntax can follow the same syntax as yaml-update but understand how to manipulate a JSON file.

As a future improvement, we could consider leaving room for different patching types (JSON Patch, JSON Merge Patch), but I would not consider this required for MVP. Also, I do not think we should support strategic merge patch, which is a can of worms I would not want to go down.

@krancour
Copy link
Member

Adding a note here that, as we discussed offline, I think it's important to preserve formatting and field order. (We took great care to do so with YAML.) If we don't it creates noise in the diffs.

Fortunately, I think this is accomplished somewhat easily with this lib: https://github.com/tidwall/sjson

@krancour krancour self-assigned this Nov 19, 2024
@krancour krancour added this to the v1.2.0 milestone Nov 19, 2024
@krancour krancour assigned fykaa and unassigned krancour Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants