Skip to content

Commit

Permalink
pkg/types/validation: Drop internal ClusterDomain
Browse files Browse the repository at this point in the history
This logic became a method in 1ab1cd3 (types: add ClusterDomain
helper for InstallConfig, 2019-01-31, #1169); so we can drop the
validation-specific helper which was from bf3ee03 (types: validate
cluster name in InstallConfig, 2019-02-14, #1255).  Or maybe we never
needed the validation-specific helper ;).
  • Loading branch information
wking committed Apr 4, 2020
1 parent f10e2d8 commit 97dfe4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
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

0 comments on commit 97dfe4d

Please sign in to comment.