argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18k stars 5.48k forks source link

Split arrays in yaml so that the first line is blank to avoid messy collapse behavior #20905

Open jsoref opened 14 hours ago

jsoref commented 14 hours ago

Summary

Currently the collapse behavior of something like this is bad:

      containers:
        - command:
            - /shared/argocd-dex
            - rundex
          env:
            - name: ARGOCD_DEX_SERVER_LOGFORMAT
              valueFrom:
                configMapKeyRef:
                  key: dexserver.log.format
                  name: argocd-cmd-params-cm
                  optional: true

There's a collapse widget to the left of - command: but it's ambiguous as to what it should collapse, it could collapse the array element, or it could collapse the command key.

If the yaml was automatically presented like this, then one could independently and unambiguously collapse the - or command::

      containers:
        -
          command:
            - /shared/argocd-dex
            - rundex
          env:
            - name: ARGOCD_DEX_SERVER_LOGFORMAT
              valueFrom:
                configMapKeyRef:
                  key: dexserver.log.format
                  name: argocd-cmd-params-cm
                  optional: true

Motivation

Typically the first item in containers: is something that would itself be collapsible, and it's incredibly frustrating to end up collapsing the entire container instead of just the first property for the container.

If the yaml was automatically presented like this, then one could easily collapse the various keys of the container without collapsing the entire container

https://cd.apps.argoproj.io/applications/argo-cd?resource=kind%3APod&node=apps%2FDeployment%2Fargocd%2Fargocd-dex-server%2F0 before:

image image

after:

image image

Proposal

When encountering an array where the first item in the array is itself collapsible, put the first item on its own line.

aali309 commented 10 hours ago

I will look into this.

andrii-korotkov-verkada commented 5 hours ago

One alternative - show two arrows on the same line, where the left one collapses - and the right one collapses command (or similar). I think an empty line with just - is not that visually appealing and it's not a display style I've seen anywhere for Yaml.