forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basedomain.go
58 lines (49 loc) · 1.43 KB
/
basedomain.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
46
47
48
49
50
51
52
53
54
55
56
57
58
package installconfig
import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
survey "gopkg.in/AlecAivazis/survey.v1"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig/aws"
"github.com/openshift/installer/pkg/validate"
)
type baseDomain struct {
BaseDomain string
}
var _ asset.Asset = (*baseDomain)(nil)
// Dependencies returns no dependencies.
func (a *baseDomain) Dependencies() []asset.Asset {
return []asset.Asset{
&platform{},
}
}
// Generate queries for the base domain from the user.
func (a *baseDomain) Generate(parents asset.Parents) error {
platform := &platform{}
parents.Get(platform)
if platform.AWS != nil {
var err error
a.BaseDomain, err = aws.GetBaseDomain()
cause := errors.Cause(err)
if !(aws.IsForbidden(cause) || request.IsErrorThrottle(cause)) {
return err
}
logrus.Error(err)
}
return survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Base Domain",
Help: "The base domain of the cluster. All DNS records will be sub-domains of this base and will also include the cluster name.",
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
return validate.DomainName(ans.(string), true)
}),
},
}, &a.BaseDomain)
}
// Name returns the human-friendly name of the asset.
func (a *baseDomain) Name() string {
return "Base Domain"
}