diff --git a/openstack/clientconfig/requests.go b/openstack/clientconfig/requests.go index 7dde8762..508f1ab1 100644 --- a/openstack/clientconfig/requests.go +++ b/openstack/clientconfig/requests.go @@ -73,13 +73,9 @@ func LoadCloudsYAML() (map[string]Cloud, error) { // LoadSecureCloudsYAML will load a secure.yaml file and return the full config. func LoadSecureCloudsYAML() (map[string]Cloud, error) { - content, err := findAndReadSecureCloudsYAML() - if err != nil { - return nil, err - } - var secureClouds Clouds - err = yaml.Unmarshal(content, &secureClouds) + + content, err := findAndReadSecureCloudsYAML() if err != nil { if err.Error() == "no secure.yaml file found" { // secure.yaml is optional so just ignore read error @@ -88,6 +84,11 @@ func LoadSecureCloudsYAML() (map[string]Cloud, error) { return nil, err } + err = yaml.Unmarshal(content, &secureClouds) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal yaml: %v", err) + } + return secureClouds.Clouds, nil }