Skip to content
Closed
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
22 changes: 17 additions & 5 deletions pkg/asset/installconfig/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ package openstack
import (
"github.com/pkg/errors"
survey "gopkg.in/AlecAivazis/survey.v1"
"sort"

"github.com/gophercloud/utils/openstack/clientconfig"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/types/openstack"
)
Expand Down Expand Up @@ -55,18 +57,28 @@ func Platform() (*openstack.Platform, error) {
return nil, err
}

cloudConfigs, err := clientconfig.LoadCloudsYAML()
if err != nil {
return nil, err
}
cloudOptions := make([]string, 0, len(cloudConfigs))
for cloudName := range cloudConfigs {
cloudOptions := append(cloudOptions, cloudName)
}
cloud, err := asset.GenerateUserProvidedAsset(
"OpenStack Cloud",
&survey.Question{
//TODO(russellb) - We could open clouds.yaml here and read the list of defined clouds
//and then use survey.Select to let the user choose one.
Prompt: &survey.Input{
Prompt: &survey.Select{
Message: "Cloud",
Help: "The OpenStack cloud name from clouds.yaml.",
Options: cloudOptions,
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
//value := ans.(string)
//FIXME(russellb) add some validation here
choice := ans.(string)
i := sort.SearchStrings(cloudOptions, choice)
if i == len(cloudOptions) || cloudOptions[i] != choice {
return errors.Errorf("Cloud %s not present in clouds.yaml", choice)
}
return nil
}),
},
Expand Down