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:
Eric Tune 2015-04-16 13:40:32 -07:00
commit e300bf3e13

View File

@ -233,6 +233,12 @@ func WriteToFile(config clientcmdapi.Config, filename string) error {
if err != nil {
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 {
return err
}