cli/command/image: rename vars that shadowed type

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-03-02 11:09:11 +01:00
parent 7a6270d190
commit c7072a885d
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -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 { 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 // 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. // tag provided in the function and then do an AddTarget later.
target := &client.Target{} notaryTarget := &client.Target{}
// Count the times of calling for handleTarget, // Count the times of calling for handleTarget,
// if it is called more that once, that should be considered an error in a trusted push. // if it is called more that once, that should be considered an error in a trusted push.
cnt := 0 cnt := 0
@ -65,12 +65,12 @@ func PushTrustedReference(ctx context.Context, ioStreams command.Streams, repoIn
if dgst, err := digest.Parse(pushResult.Digest); err == nil { if dgst, err := digest.Parse(pushResult.Digest); err == nil {
h, err := hex.DecodeString(dgst.Hex()) h, err := hex.DecodeString(dgst.Hex())
if err != nil { if err != nil {
target = nil notaryTarget = nil
return return
} }
target.Name = pushResult.Tag notaryTarget.Name = pushResult.Tag
target.Hashes = data.Hashes{string(dgst.Algorithm()): h} notaryTarget.Hashes = data.Hashes{string(dgst.Algorithm()): h}
target.Length = int64(pushResult.Size) 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") 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") 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) return trust.NotaryError(repoInfo.Name.Name(), err)
} }
_, _ = fmt.Fprintf(ioStreams.Out(), "Finished initializing %q\n", repoInfo.Name.Name()) _, _ = 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: case nil:
// already initialized and we have successfully downloaded the latest metadata // already initialized and we have successfully downloaded the latest metadata
err = trust.AddToAllSignableRoles(repo, target) err = trust.AddToAllSignableRoles(repo, notaryTarget)
default: default:
return trust.NotaryError(repoInfo.Name.Name(), err) return trust.NotaryError(repoInfo.Name.Name(), err)
} }