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

Multiline Sting replaced with escaped single line String #2030

Open
Jeansen opened this issue May 6, 2024 · 2 comments
Open

Multiline Sting replaced with escaped single line String #2030

Jeansen opened this issue May 6, 2024 · 2 comments
Labels

Comments

@Jeansen
Copy link

Jeansen commented May 6, 2024

Describe the bug
A clear and concise description of what the bug is.

Note that any how to questions should be posted in the discussion board and not raised as an issue.

Version of yq: 4.43.1
Operating system: Linux / Debian 12
Installed via: Github Release

Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data1.yml:

apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: otel-collector-daemonset
  namespace: "observability"
#  namespace: opentelemetry-operator-system
spec:
  tolerations:
    - key: CriticalAddonsOnly
      operator: Exists
    - operator: Exists
      effect: NoSchedule
    - operator: Exists
      effect: NoExecute
  mode: daemonset
  config: |
    receivers:
    # Make sure to add the otlp receiver.
    # This will open up the receiver on port 4317
    otlp:
      protocols:
        grpc:
          endpoint: "0.0.0.0:4317"
        http:
          endpoint: "0.0.0.0:4318"
    opencensus:
    zipkin:
    jaeger:
      protocols:
        grpc:
        thrift_http:
        thrift_compact:
        thrift_binary:
    processors:
      memory_limiter:
        check_interval: 1s
        limit_percentage: 50
        spike_limit_percentage: 30
      batch:
    extensions:
      health_check:
    exporters:
      debug:
      otlp/jaeger:
        endpoint: "jaeger-collector.observability.svc.cluster.local:4317"
        tls:
          insecure: true
    service:
      extensions: [health_check]
      pipelines:
        traces:
          receivers: [otlp]
          processors: [memory_limiter, batch]
          exporters: [otlp/jaeger]
        metrics:
          receivers: [otlp]
          processors: [memory_limiter]
          exporters: [debug]

Command
The command you ran:

yq file.yaml

Actual behavior

apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: otel-collector-daemonset
  namespace: "observability"
#  namespace: opentelemetry-operator-system
spec:
  tolerations:
    - key: CriticalAddonsOnly
      operator: Exists
    - operator: Exists
      effect: NoSchedule
    - operator: Exists
      effect: NoExecute
  mode: daemonset
  config: "receivers:\n# Make sure to add the otlp receiver.\n# This will open up the receiver on port 4317\notlp:\n  protocols:\n    grpc:\n      endpoint: \"0.0.0.0:4317\"\n    http:\n      endpoint: \"0.0.0.0:4318\" \nopencensus:\nzipkin:\njaeger:\n  protocols:\n    grpc:\n    thrift_http:\n    thrift_compact:\n    thrift_binary:\nprocessors:\n  memory_limiter:\n    check_interval: 1s\n    limit_percentage: 50\n    spike_limit_percentage: 30\n  batch:\nextensions:\n  health_check:\nexporters:\n  debug:\n  otlp/jaeger:\n    endpoint: \"jaeger-collector.observability.svc.cluster.local:4317\"\n    tls:\n      insecure: true\nservice:\n  extensions: [health_check]\n  pipelines:\n    traces:\n      receivers: [otlp]\n      processors: [memory_limiter, batch]\n      exporters: [otlp/jaeger]\n    metrics:\n      receivers: [otlp]\n      processors: [memory_limiter]\n      exporters: [debug]\n"

Expected behavior
No changes at all. Should be identical to input file. Instead the multi-line String was replaces with a single, long String wherein e.g. quotes and new lines are replaced with escape sequences.

Additional context
yq '.spec.config' file.yaml
In this case, the output format of this part is untouched and as expected!

@Jeansen Jeansen changed the title Multiline Stings lose their formatting. Line breaks replaces with \n Multiline Sting replaced with escaped single line String May 6, 2024
@Jeansen
Copy link
Author

Jeansen commented May 7, 2024

So, I found the problem! Whenever there is a white-space character behind any String, then a reformat happens. In the example above, there was a blank behind http.endpoint: "0.0.0.0:4318"<space>. When I removed that and printed out the file, no transformation to a single line String happened!

@Jeansen
Copy link
Author

Jeansen commented May 7, 2024

Also, this is true vor any String. Whenever there is a white-space character after any string, yq will transform multi-line Strings in a single line String.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant