mirror of
https://github.com/docker/cli.git
synced 2026-01-13 18:22:35 +03:00
Before this change, running `docker context rm --force` would fail if the context did not exist. This behavior was different from other commands, which allowed ignoring non-existing objects. For example; when trying to remove a non-existing volume, the command would fail without "force": ```bash docker volume rm nosuchvolume Error: No such volume: nosuchvolume echo $? 1 ``` But using the `-f` / `--force` option would make the command complete successfully (the error itself is still printed for informational purposes); ```bash docker volume rm -f nosuchvolume nosuchvolume echo $? 0 ``` With this patch, `docker context rm` behaves the same: ```bash docker context rm nosuchcontext context "nosuchcontext" does not exist echo $? 1 ``` ```bash docker context rm -f nosuchcontext nosuchcontext echo $? 0 ``` This patch also simplifies how we check if the context exists; previously we would try to read the context's metadata; this could fail if a context was corrupted, or if an empty directory was present. This patch now only checks if the directory exists, without first validating the context's data. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>