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

yaml line folding for long lines #161

Closed
zalyoung opened this issue Jul 1, 2020 · 3 comments
Closed

yaml line folding for long lines #161

zalyoung opened this issue Jul 1, 2020 · 3 comments
Labels
helping with an issue Debugging happening to identify the problem in progress Work has begun by a community member or a maintainer; this issue may be included in a future release

Comments

@zalyoung
Copy link

zalyoung commented Jul 1, 2020

When we use Text Template to render a notification message which will be sent to Slack, the rendered content will add a new breaking line if the content exceed a particular length and contains space.

Please help to check the below sample.

  • demo.yaml
#@ load("@ytt:data", "data")

#@ environment = data.values.environment
#@ replica = data.values.replica

subject1: #@ "{} - WARNING - The number of healthy Nginx Ingress Controller pods is not equal to {}".format(environment,replica)

#@yaml/text-templated-strings
subject2: "(@= environment @) - WARNING - The number of healthy Nginx Ingress Controller pods is not equal to (@= replica @)"
  • values.yaml
#@data/values
---
environment: Development
replica: '2'
  • Output
subject1: Development - WARNING - The number of healthy Nginx Ingress Controller pods
  is not equal to 2
subject2: Development - WARNING - The number of healthy Nginx Ingress Controller pods
  is not equal to 2
@cppforlife
Copy link
Contributor

per our slack conversation: we use yaml library that wraps long lines which is valid behaviour according to 6.5 Line Folding in YAML spec (https://yaml.org/spec/1.2/spec.html#id2779048). this low level library behaviour is not something that is configurable.

on a side note, it seems that you are using ytt to produce a block of text and you want particular formatting. you may want to consider using text templating feature (files with .txt): https://get-ytt.io/#gist:https://gist.github.com/cppforlife/256be862b3624fdb6c3e0cbcf9f57907

@cppforlife cppforlife added the helping with an issue Debugging happening to identify the problem label Jul 1, 2020
@cppforlife cppforlife changed the title Text Template create breaking line automatically yaml line folding for long lines Jul 1, 2020
@cppforlife
Copy link
Contributor

@zalyoung i have pushed a change to ytt to disable line folding after noticing that upstream yaml library decided to do that as well: 7c8609d (go-yaml/yaml#571). should be available in next ytt release.

@cppforlife cppforlife added the in progress Work has begun by a community member or a maintainer; this issue may be included in a future release label Jul 3, 2020
@cppforlife
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
helping with an issue Debugging happening to identify the problem in progress Work has begun by a community member or a maintainer; this issue may be included in a future release
Projects
None yet
Development

No branches or pull requests

2 participants