mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 12:48:51 +00:00
Loosen DNS 952 for labels
This commit is contained in:
@@ -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
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user