From c449c1a49d109a21e30e642cf6d7e5600977e39a Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Wed, 17 Apr 2024 15:21:08 +0100 Subject: [PATCH] plugins/hooks: run hooks when exit code != 0 Particularly for cases such as `docker exec -it`, it's relevant that the CLI still executes hooks even if the exec exited with a non-zero exit code, since this is can be part of a normal `docker exec` invocation depending on how the user exits. In the future, this might also be interesting to allow plugins to run hooks after an error so they can offer error-state recovery suggestions, although this would require additional work to give the plugin more information about the failed execution. Signed-off-by: Laura Brehm --- cmd/docker/docker.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index 3b3b6cb5c9..6a766ee50b 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -353,9 +353,6 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error { // which remain. cmd.SetArgs(args) err = cmd.Execute() - if err != nil { - return err - } // If the command is being executed in an interactive terminal, // run the plugin hooks (but don't throw an error if something misbehaves) @@ -363,7 +360,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error { _ = pluginmanager.RunPluginHooks(dockerCli, cmd, subCommand, "", args) } - return nil + return err } type versionDetails interface {