Skip to content
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
6 changes: 4 additions & 2 deletions pkg/asset/installconfig/clustername.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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/types"
"github.com/openshift/installer/pkg/validate"
)

Expand Down Expand Up @@ -36,7 +36,9 @@ func (a *clusterName) Generate(parents asset.Parents) error {
})
}
validator = survey.ComposeValidators(validator, func(ans interface{}) error {
return validate.DomainName(validation.ClusterDomain(bd.BaseDomain, ans.(string)), false)
installConfig := &types.InstallConfig{BaseDomain: bd.BaseDomain}
installConfig.ObjectMeta.Name = ans.(string)
return validate.DomainName(installConfig.ClusterDomain(), false)
})

return survey.Ask([]*survey.Question{
Expand Down
8 changes: 1 addition & 7 deletions pkg/types/validation/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ const (
masterPoolName = "master"
)

// ClusterDomain returns the cluster domain for a cluster with the specified
// base domain and cluster name.
func ClusterDomain(baseDomain, clusterName string) string {
return fmt.Sprintf("%s.%s", clusterName, baseDomain)
}

// ValidateInstallConfig checks that the specified install config is valid.
func ValidateInstallConfig(c *types.InstallConfig, openStackValidValuesFetcher openstackvalidation.ValidValuesFetcher) field.ErrorList {
allErrs := field.ErrorList{}
Expand Down Expand Up @@ -74,7 +68,7 @@ func ValidateInstallConfig(c *types.InstallConfig, openStackValidValuesFetcher o
allErrs = append(allErrs, field.Invalid(field.NewPath("baseDomain"), c.BaseDomain, baseDomainErr.Error()))
}
if nameErr == nil && baseDomainErr == nil {
clusterDomain := ClusterDomain(c.BaseDomain, c.ObjectMeta.Name)
clusterDomain := c.ClusterDomain()
if err := validate.DomainName(clusterDomain, true); err != nil {
allErrs = append(allErrs, field.Invalid(field.NewPath("baseDomain"), clusterDomain, err.Error()))
}
Expand Down