DockerCLI/cli/command/context
Sebastiaan van Stijn de6020a240
cli/context/store: simplify error handling, and make it more idiomatic
The package defined various special errors; these errors existed for two reasons;

- being able to distinguish "not found" errors from other errors (as "not found"
  errors can be ignored in various cases).
- to be able to update the context _name_ in the error message after the error
  was created. This was needed in cases where the name was not available at the
  location where the error was produced (e.g. only the "id" was present), and
  the helpers to detect "not found" errors did not support wrapped errors (so
  wrapping the error with a "name" could break logic); a `setContextName` interface
  and corresponding `patchErrContextName()` utility was created for this (which
  was a "creative", but not very standard approach).

This patch:

- Removes the special error-types, replacing them with errdefs definitions (which
  is a more common approach in our code-base to detect error types / classes).
- Removes the internal utilities for error-handling, and deprecates the exported
  utilities (to allow external consumers to adjust their code).
- Some errors have been enriched with detailed information (which may be useful
  for debugging / problem solving).
- Note that in some cases, `patchErrContextName()` was called, but the code
  producing the error would never return a `setContextName` error, so would
  never update the error message.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 11:19:25 +02:00
..
testdata introduce `context show` command 2022-04-25 14:40:24 +02:00
cmd.go introduce `context show` command 2022-04-25 14:40:24 +02:00
create.go cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00
create_test.go cli/command/context: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:50 +01:00
export-import_test.go cli/command/context: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:50 +01:00
export.go context export: remove docker context export --kubeconfig options 2022-02-24 12:26:09 +01:00
import.go Introduce .zip import for docker context 2019-05-29 12:58:45 -07:00
inspect.go introduce `context show` command 2022-04-25 14:40:24 +02:00
inspect_test.go cli/command/context: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:50 +01:00
list.go Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
list_test.go cli/command/context: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:50 +01:00
options.go Drop support for (archived) Compose-on-Kubernetes 2022-02-22 13:47:34 +01:00
remove.go cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00
remove_test.go cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00
show.go Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
show_test.go introduce `context show` command 2022-04-25 14:40:24 +02:00
update.go use our own version of text/tabwriter 2022-04-25 15:01:41 +02:00
update_test.go cli/command/context: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:41:50 +01:00
use.go context use: don't create/update config file and directories if not needed 2022-07-29 14:20:05 +02:00
use_test.go cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00