'yq add array element with name and subfields
I got this test.yaml:
volumes:
- name: var-log
hostPath:
path: /var/log
- name: dev-log
hostPath:
path: /dev/log
and want to achieve the following using Go yq - https://github.com/mikefarah/yq/
volumes:
- name: var-log
hostPath:
path: /var/log
- name: dev-log
hostPath:
path: /dev/log
- name: sys
mountPath: /sys
I cannot really get my head around it - with:
yq eval '.volumes |= (. + {"name":{"name":"sys"}})' test.yaml I got it almost, but the 3rd field name is missing (it should be name: sys but it is just name:)
volumes:
- name: var-log
hostPath:
path: /var/log
- name: dev-log
hostPath:
path: /dev/log
- name:
mountPath: /sys
I'm fiddling for some time now, but cannot get it working.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
