mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Update cluster name validation to allow only DNS labels
This commit is contained in:
parent
57ad590d8d
commit
473c1d5653
@ -22,7 +22,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/util/validation/field"
|
||||
)
|
||||
|
||||
var ValidateClusterName = validation.NameIsDNSSubdomain
|
||||
var ValidateClusterName = validation.NameIsDNS1035Label
|
||||
|
||||
func ValidateClusterSpec(spec *federation.ClusterSpec, fieldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
@ -61,6 +61,17 @@ func TestValidateCluster(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"invalid cluster name (is a subdomain)": {
|
||||
ObjectMeta: api.ObjectMeta{Name: "mycluster.mycompany"},
|
||||
Spec: federation.ClusterSpec{
|
||||
ServerAddressByClientCIDRs: []federation.ServerAddressByClientCIDR{
|
||||
{
|
||||
ClientCIDR: "0.0.0.0/0",
|
||||
ServerAddress: "localhost:8888",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for testName, errorCase := range errorCases {
|
||||
errs := ValidateCluster(&errorCase)
|
||||
|
Loading…
Reference in New Issue
Block a user