From 1a9566c9a9ac3febb5623bc82f3fc63e1a2d330a Mon Sep 17 00:00:00 2001 From: Jon Perritt Date: Mon, 6 Aug 2018 16:47:58 -0500 Subject: [PATCH] fix error check in LoadSecureCloudsYAML --- openstack/clientconfig/requests.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 }