Open thaJeztah opened 5 years ago
@simonferquel @chris-crone WDYT? 🤗
I love the idea. Toml seems particularly well suited for that. We need to be careful about editing contexts containing endpoints created by plugins
We need to be careful about editing contexts containing endpoints created by plugins
Good point; not fully up to speed on such cases; In that case the endpoint is managed by the plugin you mean?
FWIW, if we think this approach works, we could use docker context
as a first "PoC" (as it's all client-side), but we could consider expanding this concept to other objects (docker service edit
, docker container edit
). Perhaps one day, stacks are moved server-side (https://github.com/moby/moby/issues/26876, https://github.com/moby/moby/issues/32781, https://github.com/moby/moby/issues/35912), at which point docker stack edit
would perhaps be possible as well.
This is just a quick thought, but thought I'd write it down.
The next version of the docker cli adds a new
docker context
subcommand (https://github.com/docker/cli/pull/1501). With this subcommand, I can import, create, update, and export contexts.The current set of options per context is limited, but may be extended in future (see https://github.com/docker/cli/issues/1621 for a proposal).
Updating, or creating a context works for the current set of options, but likely doesn't scale well if there's many new options are to be added; at some point, people will have to resort to scripts to update, or create a context (
docker context update --docker foo=bar,bar=baz --kubernetes foo=bar,bar=baz
).As an alternative, users can edit the files in the context storage directly, but this may not be desirable;
In addition,
json
works great for automation, and to serialize as a string, but does not allow comments, nor may it be very user-friendly to work with.Proposal
Introduce a
docker context edit
subcommand.The
docker context edit
command, using a similar approach asgit commit
, which (I think) works something like this;~/.docker/context/CONTEXT_EDIT
)Aborting update.
)Opens an editor with the context in pretty-print;
Or, in an annotated TOML format;
After editing the file, and saving it:
When trying to update a context while another context is already in progress, an error is shown: