Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read OpenStack creds from standard paths #588

Merged
merged 2 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ ignored = ["github.com/openshift/installer/tests*"]
[[constraint]]
name = "github.com/openshift/cluster-network-operator"
revision = "fb8b55a1072436a51b153de9acf5bf5525efcf83"

[[constraint]]
name = "github.com/gophercloud/utils"
revision = "34f5991525d116b3832e0d9409492274f1c06bda"
25 changes: 9 additions & 16 deletions pkg/asset/manifests/tectonic.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -20,7 +18,6 @@ import (

const (
tectonicManifestDir = "tectonic"
openStackCredsFile = "/etc/openstack/clouds.yaml"
)

var (
Expand Down Expand Up @@ -90,10 +87,17 @@ func (t *Tectonic) Generate(dependencies asset.Parents) error {
},
}
case "openstack":
credsEncoded, err := credsFileEncode(openStackCredsFile)
flaper87 marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand Down Expand Up @@ -205,14 +209,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
}
191 changes: 191 additions & 0 deletions vendor/github.com/gophercloud/gophercloud/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading