Loosen DNS 952 for labels

This commit is contained in:
Tim Hockin
2014-11-20 14:27:11 +08:00
parent c857dc1196
commit 89875ef09d
9 changed files with 109 additions and 76 deletions

View File

@@ -428,7 +428,7 @@ func Parse(selector string) (SetBasedSelector, error) {
// TODO: unify with validation.validateLabels
func validateLabelKey(k string) error {
if !util.IsDNS952Label(k) {
if !util.IsDNSLabel(k) {
return errors.NewFieldNotSupported("key", k)
}
return nil

View File

@@ -18,6 +18,7 @@ package labels
import (
"reflect"
"strings"
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@@ -222,8 +223,9 @@ func TestRequirementConstructor(t *testing.T) {
{"x", In, util.NewStringSet("foo"), true},
{"x", NotIn, util.NewStringSet("foo"), true},
{"x", Exists, nil, true},
{"abcdefghijklmnopqrstuvwxy", Exists, nil, false}, //breaks DNS952 rule that len(key) < 25
{"1foo", In, util.NewStringSet("bar"), false}, //breaks DNS952 rule that keys start with [a-z]
{"1foo", In, util.NewStringSet("bar"), true},
{"1234", In, util.NewStringSet("bar"), true},
{strings.Repeat("a", 64), Exists, nil, false}, //breaks DNS rule that len(key) <= 63
}
for _, rc := range requirementConstructorTests {
if _, err := NewRequirement(rc.Key, rc.Op, rc.Vals); err == nil && !rc.Success {