/
clustername.go
45 lines (37 loc) · 1.37 KB
/
clustername.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
39
40
41
42
43
44
45
package installconfig
import (
survey "gopkg.in/AlecAivazis/survey.v1"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/types/validation"
"github.com/openshift/installer/pkg/validate"
)
type clusterName struct {
ClusterName string
}
var _ asset.Asset = (*clusterName)(nil)
// Dependencies returns no dependencies.
func (a *clusterName) Dependencies() []asset.Asset {
return []asset.Asset{
&baseDomain{},
}
}
// Generate queries for the cluster name from the user.
func (a *clusterName) Generate(parents asset.Parents) error {
bd := &baseDomain{}
parents.Get(bd)
return survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Cluster Name",
Help: "The name of the cluster. This will be used when generating sub-domains.\n\nFor libvirt, choose a name that is unique enough to be used as a prefix during cluster deletion. For example, if you use 'demo' as your cluster name, `openshift-install destroy cluster` may destroy all domains, networks, pools, and volumes that begin with 'demo'.",
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
return validate.DomainName(validation.ClusterDomain(bd.BaseDomain, ans.(string)), false)
}),
},
}, &a.ClusterName)
}
// Name returns the human-friendly name of the asset.
func (a *clusterName) Name() string {
return "Cluster Name"
}