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 · 44 comments
Open

Line breaks on long strings with spaces #947

maxhomann opened this issue Apr 5, 2019 · 44 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.
Projects

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).
@KnVerey
Copy link
Contributor

KnVerey commented Apr 1, 2022

v2 of go-yaml already exposes the option to change this behaviour. In fact, it was temporarily the default in v2.3 of that library, but the change was reverted at the request of the Kubernetes project in v2.4: go-yaml/yaml#670. This repo deliberately opted not to set it by default: kubernetes-sigs/yaml#62 (comment). Consumers who want the behaviour change should call yaml.FutureLineWrap(). Changing the default in kubernetes-sigs/yaml would not be possible without a major version bump IMO.

Reading through the history here and on related issues, it sounds like Kustomize in particular has already thrashed on the wrapping behaviour. Indeed, we used the go-yaml version with the changed default between #2679 and #3667, which means v3.7.0 to v4.0.5 had no line limit set, and both before and after did. The revert was apparently specifically requested because of the kubectl integration, and we knew it would thrash the line length limit: #3664.

Even if on the Kustomize side we could consider the wrapping to be purely a bug (such that we could accept the change in output as non-breaking and release without a major version bump), we would still have the problem of how to do it. Unfortunately yaml.FutureLineWrap() is a global toggle, so we cannot set it in code that kubectl will pull in, i.e. the relevant code--we already know that change is unacceptable in kubectl. So perhaps what we can do with our upcoming fork is not "fix" the wrapping (we can't change it by default), but rather expose the flag on a per-encoding basis instead of globally, so that kustomize and kubectl kustomize could make the change without affecting the rest of kubectl.

@KnVerey KnVerey added kind/bug Categorizes issue or PR as related to a bug. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API area/kyaml issues for kyaml triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 1, 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 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
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
No open projects
kanban
  
Done
Development

No branches or pull requests