mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-19 17:39:56 +00:00
Check errors of the Close call
Error from out.Close() was not checked Kubernetes-commit: f9b928f1f13821b65ea4ef783f847993c51fb4dd
This commit is contained in:
parent
6cc39819fd
commit
29b07456f5
@ -18,7 +18,6 @@ package clientcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -282,20 +281,15 @@ func (rules *ClientConfigLoadingRules) Migrate() error {
|
||||
return fmt.Errorf("cannot migrate %v to %v because it is a directory", source, destination)
|
||||
}
|
||||
|
||||
in, err := os.Open(source)
|
||||
data, err := ioutil.ReadFile(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer in.Close()
|
||||
out, err := os.Create(destination)
|
||||
// destination is created with mode 0666 before umask
|
||||
err = ioutil.WriteFile(destination, data, 0666)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
if _, err = io.Copy(out, in); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user