mirror of
https://github.com/rancher/rke.git
synced 2025-09-03 16:04:26 +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"
|
"strings"
|
||||||
|
|
||||||
"github.com/rancher/rke/services"
|
"github.com/rancher/rke/services"
|
||||||
|
"k8s.io/apimachinery/pkg/util/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Cluster) ValidateCluster() error {
|
func (c *Cluster) ValidateCluster() error {
|
||||||
@@ -67,6 +68,9 @@ func validateHostsOptions(c *Cluster) error {
|
|||||||
if len(host.Role) == 0 {
|
if len(host.Role) == 0 {
|
||||||
return fmt.Errorf("Role for host (%d) is not provided", i+1)
|
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 {
|
for _, role := range host.Role {
|
||||||
if role != services.ETCDRole && role != services.ControlRole && role != services.WorkerRole {
|
if role != services.ETCDRole && role != services.ControlRole && role != services.WorkerRole {
|
||||||
return fmt.Errorf("Role [%s] for host (%d) is not recognized", role, i+1)
|
return fmt.Errorf("Role [%s] for host (%d) is not recognized", role, i+1)
|
||||||
|
Reference in New Issue
Block a user