mirror of
https://github.com/containers/skopeo.git
synced 2025-06-27 15:18:00 +00:00
Fix error handling of signature.NewEphemeralGPGSigningMechanism
signature.NewEphemeralGPGSigningMechanism is called in an if branch where the previous err := introduces a "new" err variable, which means the failure isn't visible after the if. So, do the dumb thing and just check on both branches explicitly. (We still need to worry about correctly setting "mech" and "publicKeyfingerprints" to persist after the if.) How I hate Go sometimes. And this shows we really should update the linter. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
0f3e6e30e4
commit
4be583c8a9
@ -116,11 +116,15 @@ func (opts *standaloneVerifyOptions) run(args []string, stdout io.Writer) error
|
||||
return fmt.Errorf("Error reading public keys from %s: %w", opts.publicKeyFile, err)
|
||||
}
|
||||
mech, publicKeyfingerprints, err = signature.NewEphemeralGPGSigningMechanism(publicKeys)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error initializing GPG: %w", err)
|
||||
|
||||
}
|
||||
} else {
|
||||
mech, err = signature.NewGPGSigningMechanism()
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error initializing GPG: %w", err)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error initializing GPG: %w", err)
|
||||
}
|
||||
}
|
||||
defer mech.Close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user