From c7072a885ddb6dc3d94bece38b8c1609506a8f47 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 2 Mar 2025 11:09:11 +0100 Subject: [PATCH] cli/command/image: rename vars that shadowed type Signed-off-by: Sebastiaan van Stijn --- cli/command/image/trust.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/command/image/trust.go b/cli/command/image/trust.go index 2b4f92794c..c47e174737 100644 --- a/cli/command/image/trust.go +++ b/cli/command/image/trust.go @@ -48,7 +48,7 @@ func TrustedPush(ctx context.Context, cli command.Cli, repoInfo *registry.Reposi func PushTrustedReference(ctx context.Context, ioStreams command.Streams, repoInfo *registry.RepositoryInfo, ref reference.Named, authConfig registrytypes.AuthConfig, in io.Reader) error { // If it is a trusted push we would like to find the target entry which match the // tag provided in the function and then do an AddTarget later. - target := &client.Target{} + notaryTarget := &client.Target{} // Count the times of calling for handleTarget, // if it is called more that once, that should be considered an error in a trusted push. cnt := 0 @@ -65,12 +65,12 @@ func PushTrustedReference(ctx context.Context, ioStreams command.Streams, repoIn if dgst, err := digest.Parse(pushResult.Digest); err == nil { h, err := hex.DecodeString(dgst.Hex()) if err != nil { - target = nil + notaryTarget = nil return } - target.Name = pushResult.Tag - target.Hashes = data.Hashes{string(dgst.Algorithm()): h} - target.Length = int64(pushResult.Size) + notaryTarget.Name = pushResult.Tag + notaryTarget.Hashes = data.Hashes{string(dgst.Algorithm()): h} + notaryTarget.Length = int64(pushResult.Size) } } } @@ -99,7 +99,7 @@ func PushTrustedReference(ctx context.Context, ioStreams command.Streams, repoIn return errors.Errorf("internal error: only one call to handleTarget expected") } - if target == nil { + if notaryTarget == nil { return errors.Errorf("no targets found, provide a specific tag in order to sign it") } @@ -134,10 +134,10 @@ func PushTrustedReference(ctx context.Context, ioStreams command.Streams, repoIn return trust.NotaryError(repoInfo.Name.Name(), err) } _, _ = fmt.Fprintf(ioStreams.Out(), "Finished initializing %q\n", repoInfo.Name.Name()) - err = repo.AddTarget(target, data.CanonicalTargetsRole) + err = repo.AddTarget(notaryTarget, data.CanonicalTargetsRole) case nil: // already initialized and we have successfully downloaded the latest metadata - err = trust.AddToAllSignableRoles(repo, target) + err = trust.AddToAllSignableRoles(repo, notaryTarget) default: return trust.NotaryError(repoInfo.Name.Name(), err) }