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

3.0.1 still breaks formatting and comments #343

Closed
hassomehide opened this issue Feb 5, 2020 · 4 comments
Closed

3.0.1 still breaks formatting and comments #343

hassomehide opened this issue Feb 5, 2020 · 4 comments
Labels
Milestone

Comments

@hassomehide
Copy link

From the release notes:

Keeps yaml comments and formatting, can specify yaml tags when updating. #19, #169, #107, #171, #245, #303

Unfortunately some issues are still present.

Formatting:

spec:
  ports:
    - name: http
      port: 80
      targetPort: 80

is formatted to:

spec:
  ports:
  - name: http
    port: 80
    targetPort: 80

Notice the whitespace difference before the array element.

Comments:

Even though comments are now preserved, they seem to be re-encoded in some other encoding than UTF-8 because I'm getting back ��� instead of the symbols that were originally present in the comments.

This is the yq command I'm using:

yq write -i -d1 test.yaml 'spec.template.spec.containers(name==test).image' test-value
@itsMichaelBates
Copy link

+1 same issue (and I'm using it for exactly the same purpose as @hassomehide - updating Kubernetes deployment container images 😅)

@mikefarah
Copy link
Owner

Do you have an example for the encoding issue?
The whitespace issue is a problem of the underlying parser, however you can set an indent of 4 and that will place the arrays indented of the map. Not sure why it behaves differently with and indent of 2 - but the yaml is still valid fwiw.

@mikefarah
Copy link
Owner

Appears to be a an issue in the underlying yaml parser (yaml.v3)

go-yaml/yaml#538
and
go-yaml/yaml#578

@mikefarah mikefarah added the bug label Feb 25, 2020
@mikefarah
Copy link
Owner

Indent bug: go-yaml/yaml#559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants