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

setField removes comment in patched line #1

Closed
christophlehmann opened this issue May 26, 2023 · 3 comments
Closed

setField removes comment in patched line #1

christophlehmann opened this issue May 26, 2023 · 3 comments

Comments

@christophlehmann
Copy link
Contributor

christophlehmann commented May 26, 2023

Patch command

        {
          "path": "projects/my/project/test.yaml",
          "setField": {
            "field": "spec.values.app.image.tag",
            "value": "6.2.1"
          }
        }

Other comments in that file are kept

@hlubek
Copy link
Contributor

hlubek commented May 31, 2023

We should try to extract the SetField command and create a test case for this with some fixture YAMLs.

One way would be to unmarshal into https://pkg.go.dev/gopkg.in/yaml.v3#Node and work with the AST to set the the value (which is quite low-level) and handling cases of a key that does not exist or is not a "leaf".

We could also try to use https://pkg.go.dev/github.com/goccy/go-yaml instead.

@hlubek
Copy link
Contributor

hlubek commented May 31, 2023

@florian-kuepper Would you like to give this a try?

@hlubek
Copy link
Contributor

hlubek commented May 31, 2023

Fixed by 6b874fd

@hlubek hlubek closed this as completed May 31, 2023
hlubek added a commit that referenced this issue Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants