mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-21 00:33:15 +00:00
Add comment for the reason behind not checking empty or too-long names
Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/operation"
|
||||
"k8s.io/apimachinery/pkg/api/validate/content"
|
||||
"k8s.io/apimachinery/pkg/api/validation/path"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
)
|
||||
|
||||
@@ -145,7 +144,7 @@ func PathSegmentName[T ~string](_ context.Context, op operation.Operation, fldPa
|
||||
return nil
|
||||
}
|
||||
var allErrs field.ErrorList
|
||||
for _, msg := range path.IsValidPathSegmentName((string)(*value)) {
|
||||
for _, msg := range content.IsPathSegmentName((string)(*value)) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, *value, msg).WithOrigin("format=k8s-path-segment-name"))
|
||||
}
|
||||
return allErrs
|
||||
|
||||
@@ -416,6 +416,9 @@ func TestPathSegmentName(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
fldPath := field.NewPath("test")
|
||||
|
||||
// This format validator does not check for empty strings or max length,
|
||||
// only checks path-segment-unsafe characters. Those constraints are
|
||||
// handled by separate validators (Required, maxLength) in the schema.
|
||||
testCases := []struct {
|
||||
name string
|
||||
input string
|
||||
|
||||
Reference in New Issue
Block a user