Skip to content

Commit

Permalink
cli-plugins: RunPlugin(): rename error-variable that's possibly shadowed
Browse files Browse the repository at this point in the history
The logic in this function is confusing; let's start make it obvious where
the error that is returned is produced,

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 5, 2024
1 parent 350a0b6 commit b7695d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cli-plugins/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func RunPlugin(dockerCli *command.DockerCli, plugin *cobra.Command, meta manager

var persistentPreRunOnce sync.Once
PersistentPreRunE = func(cmd *cobra.Command, _ []string) error {
var err error
var retErr error
persistentPreRunOnce.Do(func() {
ctx, cancel := context.WithCancel(cmd.Context())
cmd.SetContext(ctx)
Expand All @@ -47,7 +47,7 @@ func RunPlugin(dockerCli *command.DockerCli, plugin *cobra.Command, meta manager
opts = append(opts, withPluginClientConn(plugin.Name()))
}
opts = append(opts, command.WithEnableGlobalMeterProvider(), command.WithEnableGlobalTracerProvider())
err = tcmd.Initialize(opts...)
retErr = tcmd.Initialize(opts...)
ogRunE := cmd.RunE
if ogRunE == nil {
ogRun := cmd.Run
Expand All @@ -67,7 +67,7 @@ func RunPlugin(dockerCli *command.DockerCli, plugin *cobra.Command, meta manager
return err
}
})
return err
return retErr
}

cmd, args, err := tcmd.HandleGlobalFlags()
Expand Down

0 comments on commit b7695d6

Please sign in to comment.