Search code examples
json-patch

Json Patch: Append multiple?


Basically, how can I can combine these two operations?

- op: add
  path: /spec/template/spec/volumes/-
  value:
    name: php-src
    emptyDir: {}
- op: add
  path: /spec/template/spec/volumes/-
  value:
    name: nginx-src
    emptyDir: {}

If I try like this, it deletes the existing entries:

- op: add
  path: /spec/template/spec/volumes
  value:
    - name: php-src
      emptyDir: {}
    - name: nginx-src
      emptyDir: {}

I just want to append two new entries to the end of /spec/template/spec/volumes which is an existing array.


Solution

  • This is not possible - the Json Patch spec only allows for adding singular values.