From e73fb7d2f69e2e993a18e2c6980266badc88acd5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 8 Mar 2025 22:43:21 +0100 Subject: [PATCH 1/2] cli/command/image: rename var that shadowed type Signed-off-by: Sebastiaan van Stijn --- cli/command/image/build.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/command/image/build.go b/cli/command/image/build.go index 039e7619ba..5db48fa9ac 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -337,13 +337,13 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) for k, auth := range creds { authConfigs[k] = registrytypes.AuthConfig(auth) } - buildOptions := imageBuildOptions(dockerCli, options) - buildOptions.Version = types.BuilderV1 - buildOptions.Dockerfile = relDockerfile - buildOptions.AuthConfigs = authConfigs - buildOptions.RemoteContext = remote + buildOpts := imageBuildOptions(dockerCli, options) + buildOpts.Version = types.BuilderV1 + buildOpts.Dockerfile = relDockerfile + buildOpts.AuthConfigs = authConfigs + buildOpts.RemoteContext = remote - response, err := dockerCli.Client().ImageBuild(ctx, body, buildOptions) + response, err := dockerCli.Client().ImageBuild(ctx, body, buildOpts) if err != nil { if options.quiet { fmt.Fprintf(dockerCli.Err(), "%s", progBuff) From 2c0f9f476d9177aeefc9e375d559726be5ea1e92 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 8 Mar 2025 22:47:56 +0100 Subject: [PATCH 2/2] cli/command/image: explicitly ignore some unhandled errs Signed-off-by: Sebastiaan van Stijn --- cli/command/image/build.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cli/command/image/build.go b/cli/command/image/build.go index 5db48fa9ac..6809845df4 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -242,7 +242,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) if err != nil { if options.quiet && urlutil.IsURL(specifiedContext) { - fmt.Fprintln(dockerCli.Err(), progBuff) + _, _ = fmt.Fprintln(dockerCli.Err(), progBuff) } return errors.Errorf("unable to prepare context: %s", err) } @@ -346,7 +346,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) response, err := dockerCli.Client().ImageBuild(ctx, body, buildOpts) if err != nil { if options.quiet { - fmt.Fprintf(dockerCli.Err(), "%s", progBuff) + _, _ = fmt.Fprintf(dockerCli.Err(), "%s", progBuff) } cancel() return err @@ -357,7 +357,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) aux := func(msg jsonstream.JSONMessage) { var result types.BuildResult if err := json.Unmarshal(*msg.Aux, &result); err != nil { - fmt.Fprintf(dockerCli.Err(), "Failed to parse aux message: %s", err) + _, _ = fmt.Fprintf(dockerCli.Err(), "Failed to parse aux message: %s", err) } else { imageID = result.ID } @@ -371,7 +371,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) jerr.Code = 1 } if options.quiet { - fmt.Fprintf(dockerCli.Err(), "%s%s", progBuff, buildBuff) + _, _ = fmt.Fprintf(dockerCli.Err(), "%s%s", progBuff, buildBuff) } return cli.StatusError{Status: jerr.Message, StatusCode: jerr.Code} } @@ -381,7 +381,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) // Windows: show error message about modified file permissions if the // daemon isn't running Windows. if response.OSType != "windows" && runtime.GOOS == "windows" && !options.quiet { - fmt.Fprintln(dockerCli.Out(), "SECURITY WARNING: You are building a Docker "+ + _, _ = fmt.Fprintln(dockerCli.Out(), "SECURITY WARNING: You are building a Docker "+ "image from Windows against a non-Windows Docker host. All files and "+ "directories added to build context will have '-rwxr-xr-x' permissions. "+ "It is recommended to double check and reset permissions for sensitive "+ @@ -502,12 +502,12 @@ func replaceDockerfileForContentTrust(ctx context.Context, inputTarStream io.Rea hdr, err := tarReader.Next() if err == io.EOF { // Signals end of archive. - tarWriter.Close() - pipeWriter.Close() + _ = tarWriter.Close() + _ = pipeWriter.Close() return } if err != nil { - pipeWriter.CloseWithError(err) + _ = pipeWriter.CloseWithError(err) return } @@ -519,7 +519,7 @@ func replaceDockerfileForContentTrust(ctx context.Context, inputTarStream io.Rea var newDockerfile []byte newDockerfile, *resolvedTags, err = rewriteDockerfileFromForContentTrust(ctx, content, translator) if err != nil { - pipeWriter.CloseWithError(err) + _ = pipeWriter.CloseWithError(err) return } hdr.Size = int64(len(newDockerfile)) @@ -527,12 +527,12 @@ func replaceDockerfileForContentTrust(ctx context.Context, inputTarStream io.Rea } if err := tarWriter.WriteHeader(hdr); err != nil { - pipeWriter.CloseWithError(err) + _ = pipeWriter.CloseWithError(err) return } if _, err := io.Copy(tarWriter, content); err != nil { - pipeWriter.CloseWithError(err) + _ = pipeWriter.CloseWithError(err) return } }