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

Line breaks on long strings with spaces #947

Open
maxhomann opened this issue Apr 5, 2019 · 48 comments
Open

Line breaks on long strings with spaces #947

maxhomann opened this issue Apr 5, 2019 · 48 comments
Labels
area/kyaml issues for kyaml kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@maxhomann
Copy link

maxhomann commented Apr 5, 2019

When combining helm templates with kustomize overlays, a line break is inserted when the line is very long and contains spaces.

Tested versions: 2.0.1 and 2.0.3
Using test/base.yml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: test
  labels:
    app.version: "{{ .Values.services.mariadb.app.version }}"
spec:
  template:
    spec:
      containers:
      - name: mariadb
        image: "thisIsAReallyLongRepositoryLinkThatResultsInALineBreakWhenBuildingWithKustomize/mariadb:{{ .Values.services.mariadb.image.version }}"

and test/kustomization.yml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- base.yml

results in

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app.version: '{{ .Values.services.mariadb.app.version }}'
  name: test
spec:
  template:
    spec:
      containers:
      - image: thisIsAReallyLongRepositoryLinkThatResultsInALineBreakWhenBuildingWithKustomize/mariadb:{{
          .Values.services.mariadb.image.version }}
        name: mariadb

Expected Behavior:

  • Line without line break
  • Also, the string/quoted value of the image name in base.yml is converted to an unqouted value on build while the app.version label is enclosed in single quotes. I would expect that either the quotes are not removed at all or the quoting behavior is constant
@maxhomann maxhomann changed the title Line break with long strings Line break on long strings with spaces Apr 5, 2019
@maxhomann maxhomann changed the title Line break on long strings with spaces Line breaks on long strings with spaces Apr 5, 2019
@laverya
Copy link
Contributor

laverya commented Apr 24, 2019

I think if go-yaml/yaml#455 gets merged that might be the signal to migrate to yaml.v3, and unlimited line lengths...

@maxhomann
Copy link
Author

This behavior is still in v3.0.1. Using the same input files, the output has line breaks:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app.version: '{{ .Values.services.mariadb.app.version }}'
  name: test
spec:
  template:
    spec:
      containers:
      - image: thisIsAReallyLongRepositoryLinkThatResultsInALineBreakWhenBuildingWithKustomize/mariadb:{{
          .Values.services.mariadb.image.version }}

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 10, 2019
@rchessa
Copy link

rchessa commented Oct 17, 2019

Hi guys,

there is a workaround for this issue?

@kristofferahl
Copy link

Have the same issue here. Need to keep the formatting as is without breaking long lines. Any ideas?

@kautsig
Copy link

kautsig commented Nov 11, 2019

@kristofferahl, we worked around this by using:

attribute: |
  very long line

Not sure if this is semantically 100% equal, though. It mitigated the issue in our specific case.

@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 11, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@laverya
Copy link
Contributor

laverya commented May 13, 2020

/reopen

@k8s-ci-robot
Copy link
Contributor

@laverya: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@laverya
Copy link
Contributor

laverya commented May 13, 2020

There's a fix in gopkg.in/yaml.v2, now released as v2.3.0 - I'll make a PR to update kustomize to this version. (basically, if the string doesn't have newline literals in it, v2.3.0 won't split the string over multiple lines when encoding things - previously it would wrap before 80 characters)

@laverya
Copy link
Contributor

laverya commented Jun 3, 2020

Just validated, and 3.6.1 still exhibits this behavior:

kustomization.yaml

resources:
- deployment.yaml

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      component: test
  template:
    metadata:
      labels:
        component: test
    spec:
      containers:
        - name: test
          image: "test"
          env:
            - name: DATABASE_URL
              value: postgres://{{repl ConfigOption "database_user"}}:{{repl ConfigOption "database_password"}}@db.{{repl Namespace}}.svc.cluster.local:5432/db

yields this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      component: test
  template:
    metadata:
      labels:
        component: test
    spec:
      containers:
      - env:
        - name: DATABASE_URL
          value: postgres://{{repl ConfigOption "database_user"}}:{{repl ConfigOption
            "database_password"}}@db.{{repl Namespace}}.svc.cluster.local:5432/db
        image: test
        name: test
$ kustomize version
{Version:3.6.1 GitCommit:c97fa946d576eb6ed559f17f2ac43b3b5a8d5dbd BuildDate:2020-05-28T01:07:36+01:00 GoOs:darwin GoArch:amd64}

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

babbageclunk added a commit to babbageclunk/azure-service-operator that referenced this issue Aug 5, 2020
Unfortunately this generated a lot of changes because descriptions are
no longer word-wrapped -  it looks like this was a change made to
kustomize last year:
kubernetes-sigs/kustomize#947

Also includes the recently added ipTags on AzurePublicIPAddresses.
babbageclunk added a commit to babbageclunk/azure-service-operator that referenced this issue Aug 5, 2020
Unfortunately this generated a lot of changes because descriptions are
no longer word-wrapped -  it looks like this was a change made to
kustomize last year:
kubernetes-sigs/kustomize#947

Also includes the recently added ipTags on AzurePublicIPAddresses.
babbageclunk added a commit to babbageclunk/azure-service-operator that referenced this issue Aug 5, 2020
The new version of kustomize no longer word-wraps long text fields
like descriptions, which causes a lot of churn in the files. This was
changed in kubernetes-sigs/kustomize#2678
released with kustomize 3.7.0 (after discussion on this bug
kubernetes-sigs/kustomize#947).
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 30, 2022
@cprivitere
Copy link
Member

/remove-lifecycle stale

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 12, 2022
@cprivitere
Copy link
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 12, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 10, 2023
@cprivitere
Copy link
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 10, 2023
@dm3ch
Copy link

dm3ch commented Apr 19, 2023

This problem is extremely annoying. Is there any updates?

Unfortunately the following workaround not works in all cases:

key: |
  value

This construction adds a \n in the end of the line and not in all cases app is able to just ignore this \n. There're |- and >- syntax, but unfortunately values created with them are still having line break in the middle of the line

@cprivitere
Copy link
Member

If I read this correctly, this may be tied to the fate of kubernetes-sigs/yaml#76

@dev-mraj
Copy link

dev-mraj commented Apr 24, 2023

adding yq in pipeline do fix this yaml

cat result.yaml | yq > new.yaml

@k8s-triage-robot
Copy link

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. and removed triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Apr 23, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 22, 2024
@stormqueen1990
Copy link
Member

stormqueen1990 commented Jul 22, 2024 via email

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 22, 2024
@antoooks
Copy link
Contributor

antoooks commented Jul 31, 2024

I tried to reproduce and can confirm that this still happens on the current version. However it only happens on a very specific situation:

  • It applies on the first occurrence only. Example: if we have this
image: "thisIsAReallyLongRepositoryLinkThatResultsInALineBreakWhenBuildingWithKustomize/mariadb:{{ .Values.services.mariadb.image.version }}:{{ .Values.someOtherVal }}"
  • It will not happen on the second :
  • It will happen if it has 64 characters preceding the :
  • It will happen with or without characters after : as long as there is a white space.

Example: If we have this

image: "1234567890123456789012345678901234567890123456789012345678901234: .s"

It will still happen

The solution is to remove white space from the helm notation {{ .Values.example }} becomes {{.Values.example}}

@koba1t
Copy link
Member

koba1t commented Aug 28, 2024

Maybe that happens in yaml.Marshal() func from yaml "sigs.k8s.io/yaml/goyaml.v2" pkg.
https://go.dev/play/p/LH-NIZT8T42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kyaml issues for kyaml kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests