diff --git a/pkg/asset/manifests/tectonic.go b/pkg/asset/manifests/tectonic.go index 1dd1c8feb4c..3ac1c0635fc 100644 --- a/pkg/asset/manifests/tectonic.go +++ b/pkg/asset/manifests/tectonic.go @@ -1,16 +1,14 @@ package manifests import ( - "bufio" "encoding/base64" - "io/ioutil" - "os" "path/filepath" "github.com/aws/aws-sdk-go/aws/session" "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 +18,6 @@ import ( const ( tectonicManifestDir = "tectonic" - openStackCredsFile = "/etc/openstack/clouds.yaml" ) var ( @@ -80,10 +77,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, @@ -176,14 +180,3 @@ func (t *Tectonic) Load(f asset.FileFetcher) (bool, error) { t.FileList, t.TectonicConfig = fileList, tectonicConfig return true, nil } - -// credsFileEncode returns contents of a file as base64 encoded string -func credsFileEncode(credsFile string) (string, error) { - f, _ := os.Open(credsFile) - reader := bufio.NewReader(f) - credsData, err := ioutil.ReadAll(reader) - if err != nil { - return "", err - } - return base64.StdEncoding.EncodeToString(credsData), nil -}