kiliantyler / yaml-formatter

Kubernetes Style YAML Formatter for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=kiliantyler.kubernetes-yaml-formatter-x
MIT License
3 stars 0 forks source link

Unexpected behavior Processing >- block #144

Open ICHx opened 2 months ago

ICHx commented 2 months ago

For scanFoldedAsLiteral to preserve linebreak Currently the plugin can handle > correctly, but not >-

  • linebreaks becomes quoted string and with \n added, which is not expected.

    Input

  • name: kube patch command: > {{ kubectl_command | default('kubectl') }} -n={{k8s_namespace}} patch service {{ lb_name }} --type=merge --patch-file="{{role_path}}/files/clb2nlb.yaml" --dry-run=client -o yaml register: patch_lb_yaml

Output

- name: kube patch {{ lb_name }} with clb2nlb.yaml
  command: >
    {{ kubectl_command | default('kubectl') }} -n={{k8s_namespace}} patch service {{ lb_name }}
    --type=merge --patch-file="{{role_path}}/files/clb2nlb.yaml" --dry-run=client -o yaml
  register: patch_lb_yaml

The >- case

Input

- name: query load balancer service
  shell: >-
    {{ kubectl_command | default('kubectl') }} get service {{ lb_name }} --namespace={{k8s_namespace}} 
    -o=jsonpath='{.status.loadBalancer.ingress[0].{% if not eks_provisioner %}ip{% else %}hostname{% endif %}}'
    {% if eks_provisioner %}; 
    {{ kubectl_command | default('kubectl') }} describe service {{ lb_name }} --namespace={{k8s_namespace}} >&2 
    {% endif %}

Current behavior

- name: query load balancer service
  shell: "{{ kubectl_command | default('kubectl') }} get service {{ lb_name }} --namespace={{k8s_namespace}}
    \n-o=jsonpath='{.status.loadBalancer.ingress[0].{% if not eks_provisioner %}ip{% else %}hostname{%
    endif %}}'\n{% if eks_provisioner %}; \n{{ kubectl_command | default('kubectl') }} describe service
    {{ lb_name }} --namespace={{k8s_namespace}} >&2 \n{% endif %}"