Skip to content

Conversation

@thaJeztah
Copy link
Member

cli/command/plugins: use errors.Join instead of custom cli.Errors

This command was using a custom "multi-error" implementation, but it
had some limitations, and the formatting wasn't great.

This patch replaces it with Go's errors.Join.

Before:

docker plugin remove one two three
Error response from daemon: plugin "one" not found, Error response from daemon: plugin "two" not found, Error response from daemon: plugin "three" not found

After:

docker plugin remove one two three
Error response from daemon: plugin "one" not found
Error response from daemon: plugin "two" not found
Error response from daemon: plugin "three" not found

cli: deprecate Errors type

The Errors type is no longer used by the CLI itself, and this custom
"multi-error" implementation had both limitations (empty list not being
nil), as well as formatting not being great. All of this making it not
something to recommend, and better handled with Go's stdlib.

As far as I could find, there's no external consumers of this, but let's
deprecate first, and remove in the next release.

- Description for the changelog

- improve formatting of errors during `docker plugin remove` 
- go-sdk: deprecate cli.Errors type in favour of Go's errors.Join

- A picture of a cute animal (not mandatory but encouraged)

This command was using a custom "multi-error" implementation, but it
had some limitations, and the formatting wasn't great.

This patch replaces it with Go's errors.Join.

Before:

    docker plugin remove one two three
    Error response from daemon: plugin "one" not found, Error response from daemon: plugin "two" not found, Error response from daemon: plugin "three" not found

After:

    docker plugin remove one two three
    Error response from daemon: plugin "one" not found
    Error response from daemon: plugin "two" not found
    Error response from daemon: plugin "three" not found

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 71ebbb8)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
The Errors type is no longer used by the CLI itself, and this custom
"multi-error" implementation had both limitations (empty list not being
`nil`), as well as formatting not being great. All of this making it not
something to recommend, and better handled with Go's stdlib.

As far as I could find, there's no external consumers of this, but let's
deprecate first, and remove in the next release.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit d3bafa5)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added this to the 27.4.0 milestone Oct 19, 2024
@thaJeztah thaJeztah self-assigned this Oct 19, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.65%. Comparing base (16201b3) to head (b3a55ec).
Report is 11 commits behind head on 27.x.

Additional details and impacted files
@@            Coverage Diff             @@
##             27.x    #5548      +/-   ##
==========================================
- Coverage   58.65%   58.65%   -0.01%     
==========================================
  Files         345      345              
  Lines       29042    29039       -3     
==========================================
- Hits        17035    17032       -3     
  Misses      11036    11036              
  Partials      971      971              

@thaJeztah thaJeztah requested a review from a team October 21, 2024 23:13
@thaJeztah thaJeztah merged commit 05c860e into docker:27.x Oct 22, 2024
114 checks passed
@thaJeztah thaJeztah deleted the 27.x_backport_plugin_better_error branch October 22, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants