yq icon indicating copy to clipboard operation
yq copied to clipboard

yq write wraps long lines

Open yene opened this issue 4 years ago • 3 comments

Describe the bug yq w -i test.yaml "spec.template.spec.containers[0].image" jupyter/datascience-notebook:1 wraps long line. I expected that it does not touch anything aside from the given path.

Thank you for taking the time to look at my report.

Input Yaml

test.yml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jupyter
spec:
  selector:
    matchLabels:
      app: jupyter
  template:
    metadata:
      labels:
        app: jupyter
        image: juypter
    spec:
      securityContext:
        fsGroup: 50000
      containers:
      - name: airflow
        image: jupyter/datascience-notebook
        args: ["start-notebook.sh", "--ip=0.0.0.0", "--NotebookApp.token=''", "--NotebookApp.password=''", "--NotebookApp.base_url='/jupyter/'"]

out.yml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jupyter
spec:
  selector:
    matchLabels:
      app: jupyter
  template:
    metadata:
      labels:
        app: jupyter
        image: juypter
    spec:
      securityContext:
        fsGroup: 50000
      containers:
      - name: airflow
        image: jupyter/datascience-notebook:1
        args: ["start-notebook.sh", "--ip=0.0.0.0", "--NotebookApp.token=''", "--NotebookApp.password=''",
          "--NotebookApp.base_url='/jupyter/'"]

Command The command you ran:

yq w -i test.yaml "spec.template.spec.containers[0].image" jupyter/datascience-notebook:1

yene avatar Jun 03 '20 12:06 yene

This is an issue with the underlying go-yaml library, it automatically line wraps and does not provide an option to turn it off (https://github.com/go-yaml/yaml/issues/387)

mikefarah avatar Jun 11 '20 03:06 mikefarah

looks like this is fixed in 2.3.0 https://github.com/go-yaml/yaml/pull/571

kungfoome avatar Feb 22 '21 15:02 kungfoome

Ah - I'm using v3 go go-yaml

mikefarah avatar Mar 01 '21 10:03 mikefarah