Skip to content

Commit

Permalink
fix: Add logic to handle for f.Close() for util/db (#9963) (#10127)
Browse files Browse the repository at this point in the history
Signed-off-by: xin.li <xin.li@daocloud.io>
  • Loading branch information
my-git9 authored Jul 28, 2022
1 parent ea5063d commit 85b4dc3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util/db/gpgkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 85b4dc3

Please sign in to comment.