forked from openshift/installer
/
libvirt.go
38 lines (33 loc) · 1.01 KB
/
libvirt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package libvirt collects libvirt-specific configuration.
package libvirt
import (
survey "gopkg.in/AlecAivazis/survey.v1"
"github.com/openshift/installer/pkg/types/libvirt"
libvirtdefaults "github.com/openshift/installer/pkg/types/libvirt/defaults"
"github.com/openshift/installer/pkg/validate"
)
// Platform collects libvirt-specific configuration.
func Platform() (*libvirt.Platform, error) {
var uri string
err := survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Libvirt Connection URI",
Help: "The libvirt connection URI to be used. This must be accessible from the running cluster.",
Default: libvirtdefaults.DefaultURI,
},
Validate: survey.ComposeValidators(survey.Required, uriValidator),
},
}, &uri)
if err != nil {
return nil, err
}
return &libvirt.Platform{
URI: uri,
}, nil
}
// uriValidator validates if the answer provided in prompt is a valid
// url and has non-empty scheme.
func uriValidator(ans interface{}) error {
return validate.URI(ans.(string))
}