Skip to content

Commit

Permalink
Merge pull request gophercloud#65 from jrperritt/64
Browse files Browse the repository at this point in the history
fix error check in LoadSecureCloudsYAML
  • Loading branch information
jtopjian authored Aug 6, 2018
2 parents 259b9db + 1a9566c commit d6e28a8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions openstack/clientconfig/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit d6e28a8

Please sign in to comment.