mirror of
https://github.com/rancher/rke.git
synced 2025-09-01 23:16:22 +00:00
Validate hostname_override values
This commit is contained in:
committed by
Alena Prokharchyk
parent
9c172c40b2
commit
4b3068d673
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/rke/services"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
)
|
||||
|
||||
func (c *Cluster) ValidateCluster() error {
|
||||
@@ -67,6 +68,9 @@ func validateHostsOptions(c *Cluster) error {
|
||||
if len(host.Role) == 0 {
|
||||
return fmt.Errorf("Role for host (%d) is not provided", i+1)
|
||||
}
|
||||
if errs := validation.IsDNS1123Subdomain(host.HostnameOverride); len(errs) > 0 {
|
||||
return fmt.Errorf("Hostname_override [%s] for host (%d) is not valid: %v", host.HostnameOverride, i+1, errs)
|
||||
}
|
||||
for _, role := range host.Role {
|
||||
if role != services.ETCDRole && role != services.ControlRole && role != services.WorkerRole {
|
||||
return fmt.Errorf("Role [%s] for host (%d) is not recognized", role, i+1)
|
||||
|
Reference in New Issue
Block a user