mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Merge pull request #6922 from fabianofranz/fix_config_dir_creation
Create complete parent dir structure when saving config to file
This commit is contained in:
commit
e300bf3e13
@ -233,6 +233,12 @@ func WriteToFile(config clientcmdapi.Config, filename string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
dir := filepath.Dir(filename)
|
||||||
|
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||||
|
if err = os.MkdirAll(dir, 0755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
if err := ioutil.WriteFile(filename, content, 0600); err != nil {
|
if err := ioutil.WriteFile(filename, content, 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user