From bf2dae22de2e0ff9b19f1d2ced25742b2f63423b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 8 Jan 2025 12:48:15 +0100 Subject: [PATCH] cli/command/plugin: runCreate: minor cleanup Signed-off-by: Sebastiaan van Stijn --- cli/command/plugin/create.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cli/command/plugin/create.go b/cli/command/plugin/create.go index c81bab3338e6..13b4589335ee 100644 --- a/cli/command/plugin/create.go +++ b/cli/command/plugin/create.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io" "os" "path/filepath" @@ -35,7 +34,7 @@ func validateConfig(path string) error { m := types.PluginConfig{} err = json.NewDecoder(dt).Decode(&m) - dt.Close() + _ = dt.Close() return err } @@ -87,11 +86,6 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command { } func runCreate(ctx context.Context, dockerCli command.Cli, options pluginCreateOptions) error { - var ( - createCtx io.ReadCloser - err error - ) - if err := validateTag(options.repoName); err != nil { return err } @@ -111,17 +105,17 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options pluginCreateO compression = archive.Gzip } - createCtx, err = archive.TarWithOptions(absContextDir, &archive.TarOptions{ + createCtx, err := archive.TarWithOptions(absContextDir, &archive.TarOptions{ Compression: compression, }) if err != nil { return err } - createOptions := types.PluginCreateOptions{RepoName: options.repoName} - if err = dockerCli.Client().PluginCreate(ctx, createCtx, createOptions); err != nil { + err = dockerCli.Client().PluginCreate(ctx, createCtx, types.PluginCreateOptions{RepoName: options.repoName}) + if err != nil { return err } - fmt.Fprintln(dockerCli.Out(), options.repoName) + _, _ = fmt.Fprintln(dockerCli.Out(), options.repoName) return nil }