From abd02b6a2369a0ac5b4062fb51b3f2cd3f8226df Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 18 Mar 2025 11:13:29 +0100 Subject: [PATCH] cli-plugins/manager: ListPlugins: pass context to error-group This error-group was added in 89583b92b74ec3c2dfe770b0c01437b1e373c1aa, but passed a context.TODO because the function didn't have a context as argument. However, it does get the root-command passed, which holds the context, so we can pass that. Signed-off-by: Sebastiaan van Stijn --- cli-plugins/manager/manager.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli-plugins/manager/manager.go b/cli-plugins/manager/manager.go index 4b553eae79..e1cdbce30a 100644 --- a/cli-plugins/manager/manager.go +++ b/cli-plugins/manager/manager.go @@ -154,7 +154,12 @@ func ListPlugins(dockerCli config.Provider, rootcmd *cobra.Command) ([]Plugin, e var plugins []Plugin var mu sync.Mutex - eg, _ := errgroup.WithContext(context.TODO()) + ctx := rootcmd.Context() + if ctx == nil { + // Fallback, mostly for tests that pass a bare cobra.command + ctx = context.Background() + } + eg, _ := errgroup.WithContext(ctx) cmds := rootcmd.Commands() for _, paths := range candidates { func(paths []string) {