diff --git a/util/db/gpgkeys.go b/util/db/gpgkeys.go index 8a03c35bd45ca..1c051a1c5f705 100644 --- a/util/db/gpgkeys.go +++ b/util/db/gpgkeys.go @@ -24,7 +24,12 @@ func validatePGPKey(keyData string) (*appsv1.GnuPGPublicKey, error) { if err != nil { return nil, err } - defer f.Close() + defer func() { + err = f.Close() + if err != nil { + log.Errorf("error closing file %q: %v", f.Name(), err) + } + }() parsed, err := gpg.ValidatePGPKeys(f.Name()) if err != nil {