mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-21 18:32:50 +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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"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)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer in.Close()
|
// destination is created with mode 0666 before umask
|
||||||
out, err := os.Create(destination)
|
err = ioutil.WriteFile(destination, data, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer out.Close()
|
|
||||||
|
|
||||||
if _, err = io.Copy(out, in); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user