Skip to content

Commit

Permalink
#31 Openstack create config does not create auto folders
Browse files Browse the repository at this point in the history
- Bugfix
  • Loading branch information
Victor Getz committed May 5, 2023
1 parent 7b10a1b commit 2da7e29
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package openstack
import (
"github.com/gophercloud/utils/openstack/clientconfig"
"gopkg.in/yaml.v2"
"os"
"otc-auth/common"
"otc-auth/common/endpoints"
"otc-auth/config"
"path"
"path/filepath"
)

func WriteOpenStackCloudsYaml(openStackConfigFileLocation string) {
Expand Down Expand Up @@ -48,11 +50,13 @@ func createOpenstackCloudsYAML(clouds clientconfig.Clouds, openStackConfigFileLo
}

if openStackConfigFileLocation == "" {
configFilePath := path.Join(config.GetHomeFolder(), ".config", "openstack", "clouds.yaml")
config.WriteConfigFile(string(contentAsBytes), configFilePath)
} else {
config.WriteConfigFile(string(contentAsBytes), openStackConfigFileLocation)
openStackConfigFileLocation = path.Join(config.GetHomeFolder(), ".config", "openstack", "clouds.yaml")
}
mkDirError := os.MkdirAll(filepath.Dir(openStackConfigFileLocation), os.ModePerm)
if mkDirError != nil {
common.OutputErrorMessageToConsoleAndExit(err.Error())
}
config.WriteConfigFile(string(contentAsBytes), openStackConfigFileLocation)

println("info: openstack clouds.yaml was updated")
}

0 comments on commit 2da7e29

Please sign in to comment.