From ccd142f950746690f263e178790fe480ff878b4a Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Mon, 5 Nov 2018 09:28:40 +0100 Subject: [PATCH] Read OpenStack creds from standard paths OpenStack creds cold be in 3 different paths (etc, home config and current dir). Instead of re-implementing the logic to find and read the clouds.yaml file, we should use gophercloud which is the standard go library for OpenStack. Note that deployments on OpenStack are currently broken unless there's a clouds.yaml under /etc/openstack. Fixes #550 --- pkg/asset/manifests/tectonic.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/asset/manifests/tectonic.go b/pkg/asset/manifests/tectonic.go index 1dd1c8feb4c..e077403740e 100644 --- a/pkg/asset/manifests/tectonic.go +++ b/pkg/asset/manifests/tectonic.go @@ -11,6 +11,7 @@ import ( "github.com/ghodss/yaml" "github.com/pkg/errors" + "github.com/gophercloud/utils/openstack/clientconfig" "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/installconfig" "github.com/openshift/installer/pkg/asset/machines" @@ -20,7 +21,6 @@ import ( const ( tectonicManifestDir = "tectonic" - openStackCredsFile = "/etc/openstack/clouds.yaml" ) var ( @@ -80,10 +80,17 @@ func (t *Tectonic) Generate(dependencies asset.Parents) error { }, } case "openstack": - credsEncoded, err := credsFileEncode(openStackCredsFile) + clouds, err := clientconfig.LoadCloudsYAML() if err != nil { return err } + + marshalled, err := yaml.Marshal(clouds) + if err != nil { + return err + } + + credsEncoded := base64.StdEncoding.EncodeToString(marshalled) cloudCreds = cloudCredsSecretData{ OpenStack: &OpenStackCredsSecretData{ Base64encodeCloudCreds: credsEncoded,