Update cluster name validation to allow only DNS labels

This commit is contained in:
nikhiljindal 2016-08-18 18:19:19 -07:00
parent 57ad590d8d
commit 473c1d5653
2 changed files with 12 additions and 1 deletions

View File

@ -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{}

View File

@ -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)