Home > Mobile >  multiline yaml keys without spaces
multiline yaml keys without spaces

Time:12-02

one of my keys in a Kubernetes deployment is really big and I want to break it into a multi line key:

annotations:
  container.apparmor.security.beta.kubernetes.io/9c2591b6-bd95-442a-9d35-fb600143a873: runtime/default

I tried this:

annotations:
  ? >-
    container.apparmor.security.beta.kubernetes.io/
    9c2591b6-bd95-442a-9d35-fb600143a873
  : runtime/default

but it renders like that:

annotations:
  container.apparmor.security.beta.kubernetes.io/ 9c2591b6-bd95-442a-9d35-fb600143a873: runtime/default

Any idea who to break object key into a multi line string without any spaces?
I found a lot of solutions for multi line strings of the keys value but nothing regarding the key itself.

Thanks in advance

CodePudding user response:

Use double quotes and escape the newlines:

annotations:
  ? "container.apparmor.security.beta.kubernetes.io/\
    9c2591b6-bd95-442a-9d35-fb600143a873"
  : runtime/default

Double quotes are the only YAML scalar that can be broken anywhere with an escaped newline.

  • Related