From 5d3bdf8ac24814673531be9cd33f554a0cfdbef5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 1 Feb 2025 22:38:48 +0100 Subject: [PATCH] cli/command/manifest: minor cleanups: use Println, rename vars - use Println to print newline instead of custom format - use dockerCLI with Go's standard camelCase casing. - suppress some errors to make my IDE and linters happier Signed-off-by: Sebastiaan van Stijn --- cli/command/manifest/create_list.go | 8 ++++---- cli/command/manifest/push.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cli/command/manifest/create_list.go b/cli/command/manifest/create_list.go index ac78b14f62..d6ca591ab2 100644 --- a/cli/command/manifest/create_list.go +++ b/cli/command/manifest/create_list.go @@ -35,7 +35,7 @@ func newCreateListCommand(dockerCli command.Cli) *cobra.Command { return cmd } -func createManifestList(ctx context.Context, dockerCli command.Cli, args []string, opts createOpts) error { +func createManifestList(ctx context.Context, dockerCLI command.Cli, args []string, opts createOpts) error { newRef := args[0] targetRef, err := normalizeReference(newRef) if err != nil { @@ -47,7 +47,7 @@ func createManifestList(ctx context.Context, dockerCli command.Cli, args []strin return errors.Wrapf(err, "error parsing repository name for manifest list %s", newRef) } - manifestStore := dockerCli.ManifestStore() + manifestStore := dockerCLI.ManifestStore() _, err = manifestStore.GetList(targetRef) switch { case store.IsNotFound(err): @@ -68,7 +68,7 @@ func createManifestList(ctx context.Context, dockerCli command.Cli, args []strin return err } - manifest, err := getManifest(ctx, dockerCli, targetRef, namedRef, opts.insecure) + manifest, err := getManifest(ctx, dockerCLI, targetRef, namedRef, opts.insecure) if err != nil { return err } @@ -76,6 +76,6 @@ func createManifestList(ctx context.Context, dockerCli command.Cli, args []strin return err } } - fmt.Fprintf(dockerCli.Out(), "Created manifest list %s\n", targetRef.String()) + _, _ = fmt.Fprintln(dockerCLI.Out(), "Created manifest list", targetRef.String()) return nil } diff --git a/cli/command/manifest/push.go b/cli/command/manifest/push.go index 29fcffe30f..67c370ec78 100644 --- a/cli/command/manifest/push.go +++ b/cli/command/manifest/push.go @@ -268,13 +268,13 @@ func buildPutManifestRequest(imageManifest types.ImageManifest, targetRef refere return mountRequest{ref: mountRef, manifest: imageManifest}, err } -func pushList(ctx context.Context, dockerCli command.Cli, req pushRequest) error { - rclient := dockerCli.RegistryClient(req.insecure) +func pushList(ctx context.Context, dockerCLI command.Cli, req pushRequest) error { + rclient := dockerCLI.RegistryClient(req.insecure) if err := mountBlobs(ctx, rclient, req.targetRef, req.manifestBlobs); err != nil { return err } - if err := pushReferences(ctx, dockerCli.Out(), rclient, req.mountRequests); err != nil { + if err := pushReferences(ctx, dockerCLI.Out(), rclient, req.mountRequests); err != nil { return err } dgst, err := rclient.PutManifest(ctx, req.targetRef, req.list) @@ -282,7 +282,7 @@ func pushList(ctx context.Context, dockerCli command.Cli, req pushRequest) error return err } - fmt.Fprintln(dockerCli.Out(), dgst.String()) + _, _ = fmt.Fprintln(dockerCLI.Out(), dgst.String()) return nil } @@ -292,7 +292,7 @@ func pushReferences(ctx context.Context, out io.Writer, client registryclient.Re if err != nil { return err } - fmt.Fprintf(out, "Pushed ref %s with digest: %s\n", mount.ref, newDigest) + _, _ = fmt.Fprintf(out, "Pushed ref %s with digest: %s\n", mount.ref, newDigest) } return nil }