Ryebridge:
Hey Guys, for an array like this for example
httpHeaders:
- name: Custom-Header
value: Awesome
Does it matter where you have the - value like can we switch to this for example:
httpHeaders:
name: Custom-Header
- value: Awesome
When editing I sometimes come across sections like this or am I just imagining things ?!
Aditya Samant:
I’ve never seen an example like the second one.
Alistair Mackay:
The second one is invalid YAML.
This would be valid though
httpHeaders:
- value: Awesome
name: Custom-Header
In your example httpHeaders
is a list
of object
where the object has fields name
and value
. The order of the fields in a YAML object representation is not significant, but the position of the -
relating to the parent key httpHeaders
is.
https://github.com/kodekloudhub/community-faq/blob/main/docs/yaml-faq.md
Alistair Mackay:
If you wanted more object in the list
httpHeaders:
- value: Awesome
name: Custom-Header
- name: Header2
value: my-value
… also valid