Description
There are some pretty valuable use cases for have a move/copy functionality, primarily when you want to re-arrange nested objects.
For example, suppose you have a yaml file like a BOSH manifest with the following structure:
instance_groups:
- name: api
jobs:
- name: api-server
properties:
db_string: mysql://mysql.example.com:3306
- name: api-worker
properties:
db_string: mysql://mysql.example.com:3306
<lots and lots of configuration...>
In BOSH land, if you wanted to scale the workers without scaling the servers, you'd have place the api-worker
job in a different instance_group and then scale that separately. That would mean you'd want to end up with the following yaml:
instance_groups:
- name: api
jobs:
- name: api-server
properties:
db_string: mysql://mysql.example.com:3306
- name: worker
jobs:
- name: api-worker
properties:
db_string: mysql://mysql.example.com:3306
<lots and lots of configuration...>
It should be easy, except that your operation definition would need to know the internal data of the yaml you're operating on:
- type: replace
path: /instance_groups/-
value:
name: worker
jobs:
- name: api-worker
properties:
db_string: mysql://mysql.example.com:3306
<lots and lots of configuration...>
You have to copy all of the data that already exists in the yaml being operated on. With a move
functionality, on the other hand, you'd be able to write something like the following operation instead:
- type: replace
path: /instance_groups/-
value:
name: worker
jobs: ~
- type: move
from: /instance_groups/name=api/jobs/name=worker
path: /instance_groups/name=worker/jobs/-
Or, if you're super cool:
- type: move
from: /instance_groups/name=api/jobs/name=worker
path: /instance_groups?/name=worker/jobs/-
No knowledge of the internals of api-worker
required. A copy
could function the same way.
Would this be a reasonable interface for move
/copy
? Is something that could get added? Asking for a friend.