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

ytt formatting converts multi line strings to single line strings due to trailing spaces #847

Open
fritzduchardt opened this issue Jun 5, 2023 · 6 comments
Assignees
Labels
blocked on upstream Feature is blocked on upstream project bug This issue describes a defect or unexpected behavior

Comments

@fritzduchardt
Copy link

What steps did you take:
I am running ytt on a config map with a multi line string and a trailing space after the colon in line 7, e.g.:

  1 apiVersion: v1
  2 kind: ConfigMap
  3 metadata:
  4   name: my-config.map
  5 data:
  6   config: |
  7     metricsConfig: 
  8       enabled: true
  9       path: /metrics
 10       port: 9090
 11       ignoreErrors: false
 12       secure: false

What happened:
Ytt unexpectedly converts the multi-line string to a single-line string:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config.map
data:
  config: "metricsConfig: \n  enabled: true\n  path: /metrics\n  port: 9090\n  ignoreErrors: false\n  secure: false\n"

What did you expect:
The multi-line string should be kept. The trailing white space could be removed.

Environment:

  • ytt version (use ytt --version): 0.44.0
  • OS (e.g. from /etc/os-release): Ubuntu 20.04.4 LTS

Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@fritzduchardt fritzduchardt added bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance labels Jun 5, 2023
@dteoh
Copy link

dteoh commented Jun 7, 2023

I don't have any errant trailing spaces in my multi-line strings but recently also saw that ytt is now collapsing everything into a very long single line string, so it would be great to get this behaviour reverted or configurable.

@sethiyash
Copy link
Contributor

sethiyash commented Jun 7, 2023

I'm able to successfully reproduce this issue. We will run our thoughts on this internally and set the priority accordingly.

Meanwhile, if you are willing to contribute, we will be happy to review it on a priority basis.

@sethiyash sethiyash added carvel accepted This issue should be considered for future work and that the triage process has been completed and removed carvel triage This issue has not yet been triaged for relevance labels Jun 7, 2023
@vmunishwar
Copy link
Contributor

Also, could you please let us know if this is a blocking issue for your use case or you found any workaround?

@fritzduchardt
Copy link
Author

My current workaround is to run sed -r " s#:\s+$#:#g" on my yamls before handing them to ytt.

fritzduchardt added a commit to fritzduchardt/ytt that referenced this issue Jun 17, 2023
Signed-off-by: Fritz Duchardt <fritz@duchardt.net>
@fritzduchardt
Copy link
Author

@sethiyash Please have a look at my PR to fix the issue

@vmunishwar vmunishwar self-assigned this Jul 5, 2023
@vmunishwar
Copy link
Contributor

vmunishwar commented Jul 12, 2023

@fritzduchardt Thank you for reaching out with this issue and we appreciate the work you have done to fix it.
However, this seems to be an issue present in yaml.v2 library which is used in ytt and also we verified that this issue is present in yaml.v3 library. It would be nice if we can raise this PR in API v2 of the yaml package for Go. Please let us know your thoughts on this. Thank you.

@vmunishwar vmunishwar removed the carvel accepted This issue should be considered for future work and that the triage process has been completed label Jul 12, 2023
@renuy renuy added the blocked on upstream Feature is blocked on upstream project label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked on upstream Feature is blocked on upstream project bug This issue describes a defect or unexpected behavior
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

5 participants