Skip to content

Commit 240b069

Browse files
committed
cli-plugins/plugin: rewrite withPluginClientConn w/ WithAPIClient
The WithInitializeClient looks redundant altogether, so let's rewrite this function to not depend on it. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 7b1f889 commit 240b069

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

cli-plugins/plugin/plugin.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func Run(makeCmd func(command.Cli) *cobra.Command, meta metadata.Metadata) {
109109
}
110110

111111
func withPluginClientConn(name string) command.CLIOption {
112-
return command.WithInitializeClient(func(dockerCli *command.DockerCli) (client.APIClient, error) {
112+
return func(cli *command.DockerCli) error {
113113
cmd := "docker"
114114
if x := os.Getenv(metadata.ReexecEnvvar); x != "" {
115115
cmd = x
@@ -133,11 +133,14 @@ func withPluginClientConn(name string) command.CLIOption {
133133

134134
helper, err := connhelper.GetCommandConnectionHelper(cmd, flags...)
135135
if err != nil {
136-
return nil, err
136+
return err
137137
}
138-
139-
return client.NewClientWithOpts(client.WithDialContext(helper.Dialer))
140-
})
138+
apiClient, err := client.NewClientWithOpts(client.WithDialContext(helper.Dialer))
139+
if err != nil {
140+
return err
141+
}
142+
return command.WithAPIClient(apiClient)(cli)
143+
}
141144
}
142145

143146
func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta metadata.Metadata) *cli.TopLevelCommand {

0 commit comments

Comments
 (0)