DockerCLI/cli/command
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
..
builder Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
checkpoint completion v2: some small follow-ups 2022-05-12 13:25:15 +02:00
commands remove exec, push, pull, ps, images, info from "legacy" commands 2022-04-08 16:55:39 +02:00
completion Adopt Cobra completion v2 to support completion by CLI plugins 2022-05-12 12:59:10 +02:00
config linting: ST1005: error strings should not be capitalized (stylecheck) 2022-09-03 21:25:42 +02:00
container Merge pull request #3764 from thaJeztah/cli_remove_intermediate_var 2022-09-08 16:14:20 +02:00
context cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00
formatter linting: tabwriter: ignore stylecheck 2022-09-03 21:25:39 +02:00
idresolver bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
image replace uses of deprecated env.Patch() 2022-09-22 17:28:07 +02:00
inspect linting: fix incorrectly formatted errors (revive) 2022-03-28 10:37:25 +02:00
manifest linting: ST1019: package is being imported more than once (stylecheck) 2022-09-03 21:25:36 +02:00
network format (GoDoc) comments with Go 1.19 to prepare for go updates 2022-07-19 19:10:16 +02:00
node linting: ST1005: error strings should not be capitalized (stylecheck) 2022-09-03 21:25:42 +02:00
plugin completion v2: some small follow-ups 2022-05-12 13:25:15 +02:00
registry format (GoDoc) comments with Go 1.19 to prepare for go updates 2022-07-19 19:10:16 +02:00
secret linting: ST1005: error strings should not be capitalized (stylecheck) 2022-09-03 21:25:42 +02:00
service linting: remove unused nolint comments (nolintlint) 2022-09-03 21:25:34 +02:00
stack linting: ST1019: package is being imported more than once (stylecheck) 2022-09-03 21:25:36 +02:00
swarm linting: ST1005: error strings should not be capitalized (stylecheck) 2022-09-03 21:25:42 +02:00
system Merge pull request #3656 from thaJeztah/fix_info_empty_labels 2022-07-19 21:09:25 +02:00
task linting: fix incorrectly formatted errors (revive) 2022-03-28 10:37:25 +02:00
testdata Dynamically register kubernetes context store endpoint type. 2019-05-20 13:28:11 +01:00
trust linting: ST1005: error strings should not be capitalized (stylecheck) 2022-09-03 21:25:42 +02:00
volume Deflake TestVolumeCreateClusterOpts 2022-06-03 11:52:51 +02:00
cli.go cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00
cli_options.go cli/command: remove WithContextEndpointType() as it's unused 2022-07-21 18:11:50 +02:00
cli_options_test.go linting: os.Setenv() can be replaced by `t.Setenv()` (tenv) 2022-09-03 21:25:37 +02:00
cli_test.go replace uses of deprecated env.Patch() 2022-09-22 17:28:07 +02:00
context.go remove obsolete mutli-orchestrator support 2022-02-22 15:28:12 +01:00
context_test.go remove obsolete mutli-orchestrator support 2022-02-22 15:28:12 +01:00
defaultcontextstore.go cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00
defaultcontextstore_test.go cli/context/store: simplify error handling, and make it more idiomatic 2022-09-30 11:19:25 +02:00
events_utils.go updated vendoring 2017-09-01 19:41:06 -04:00
registry.go registry: don't call "/info" API endpoint to get default registry 2022-03-15 16:30:42 +01:00
registry_test.go registry: don't call "/info" API endpoint to get default registry 2022-03-15 16:30:42 +01:00
streams.go Extract streams helpers from command package to their own package to remove a cyclic dependency from command to internal/containerizedengine 2019-01-28 14:36:00 +01:00
trust.go Refactor content_trust cli/flags handling 2018-03-08 15:00:43 -05:00
utils.go replace pkg/system Sequential funcs with moby/sys/sequential 2022-08-29 13:27:26 +02:00
utils_test.go cli/command: remove deprecated io/ioutil and use t.TempDir() 2022-02-25 15:42:14 +01:00