mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-26 08:10:20 +00:00
cleanup: return error type in util.storeKey()
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
f8ebc6aa3f
commit
c8c8176a37
@ -42,7 +42,7 @@ type Credentials struct {
|
|||||||
func storeKey(key string) (string, error) {
|
func storeKey(key string) (string, error) {
|
||||||
tmpfile, err := ioutil.TempFile(tmpKeyFileLocation, tmpKeyFileNamePrefix)
|
tmpfile, err := ioutil.TempFile(tmpKeyFileLocation, tmpKeyFileNamePrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error creating a temporary keyfile (%s)", err)
|
return "", fmt.Errorf("error creating a temporary keyfile: %w", err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -52,17 +52,17 @@ func storeKey(key string) (string, error) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
if _, err = tmpfile.Write([]byte(key)); err != nil {
|
if _, err = tmpfile.Write([]byte(key)); err != nil {
|
||||||
return "", fmt.Errorf("error writing key to temporary keyfile (%s)", err)
|
return "", fmt.Errorf("error writing key to temporary keyfile: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
keyFile := tmpfile.Name()
|
keyFile := tmpfile.Name()
|
||||||
if keyFile == "" {
|
if keyFile == "" {
|
||||||
err = fmt.Errorf("error reading temporary filename for key (%s)", err)
|
err = fmt.Errorf("error reading temporary filename for key: %w", err)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = tmpfile.Close(); err != nil {
|
if err = tmpfile.Close(); err != nil {
|
||||||
return "", fmt.Errorf("error closing temporary filename (%s)", err)
|
return "", fmt.Errorf("error closing temporary filename: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyFile, nil
|
return keyFile, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user