mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Merge pull request #128553 from thockin/master
Validation: merge TooLong and TooLongMaxLen
This commit is contained in:
@@ -54,7 +54,7 @@ func ValidateSignerName(fldPath *field.Path, signerName string) field.ErrorList
|
||||
// validate that segments[0] is less than 253 characters altogether
|
||||
maxDomainSegmentLength := validation.DNS1123SubdomainMaxLength
|
||||
if len(segments[0]) > maxDomainSegmentLength {
|
||||
el = append(el, field.TooLong(fldPath, segments[0], maxDomainSegmentLength))
|
||||
el = append(el, field.TooLong(fldPath, "" /*unused*/, maxDomainSegmentLength))
|
||||
}
|
||||
// validate that segments[0] consists of valid DNS1123 labels separated by '.'
|
||||
domainLabels := strings.Split(segments[0], ".")
|
||||
@@ -97,7 +97,7 @@ func ValidateSignerName(fldPath *field.Path, signerName string) field.ErrorList
|
||||
maxPathSegmentLength := validation.DNS1123SubdomainMaxLength + validation.DNS1123LabelMaxLength + 1
|
||||
maxSignerNameLength := maxDomainSegmentLength + maxPathSegmentLength + 1
|
||||
if len(signerName) > maxSignerNameLength {
|
||||
el = append(el, field.TooLong(fldPath, signerName, maxSignerNameLength))
|
||||
el = append(el, field.TooLong(fldPath, "" /*unused*/, maxSignerNameLength))
|
||||
}
|
||||
|
||||
return el
|
||||
|
||||
@@ -1685,7 +1685,7 @@ func ValidateCSIDriverName(driverName string, fldPath *field.Path) field.ErrorLi
|
||||
}
|
||||
|
||||
if len(driverName) > 63 {
|
||||
allErrs = append(allErrs, field.TooLong(fldPath, driverName, 63))
|
||||
allErrs = append(allErrs, field.TooLong(fldPath, "" /*unused*/, 63))
|
||||
}
|
||||
|
||||
for _, msg := range validation.IsDNS1123Subdomain(strings.ToLower(driverName)) {
|
||||
@@ -4772,7 +4772,7 @@ func ValidateAppArmorProfileField(profile *core.AppArmorProfile, fldPath *field.
|
||||
|
||||
const maxLocalhostProfileLength = 4095 // PATH_MAX - 1
|
||||
if len(*profile.LocalhostProfile) > maxLocalhostProfileLength {
|
||||
allErrs = append(allErrs, field.TooLongMaxLength(fldPath.Child("localhostProfile"), *profile.LocalhostProfile, maxLocalhostProfileLength))
|
||||
allErrs = append(allErrs, field.TooLong(fldPath.Child("localhostProfile"), "" /*unused*/, maxLocalhostProfileLength))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6589,7 +6589,7 @@ func ValidateSecret(secret *core.Secret) field.ErrorList {
|
||||
totalSize += len(value)
|
||||
}
|
||||
if totalSize > core.MaxSecretSize {
|
||||
allErrs = append(allErrs, field.TooLong(dataPath, "", core.MaxSecretSize))
|
||||
allErrs = append(allErrs, field.TooLong(dataPath, "" /*unused*/, core.MaxSecretSize))
|
||||
}
|
||||
|
||||
switch secret.Type {
|
||||
@@ -6704,7 +6704,7 @@ func ValidateConfigMap(cfg *core.ConfigMap) field.ErrorList {
|
||||
}
|
||||
if totalSize > core.MaxSecretSize {
|
||||
// pass back "" to indicate that the error refers to the whole object.
|
||||
allErrs = append(allErrs, field.TooLong(field.NewPath(""), cfg, core.MaxSecretSize))
|
||||
allErrs = append(allErrs, field.TooLong(field.NewPath(""), "" /*unused*/, core.MaxSecretSize))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
|
||||
@@ -11928,7 +11928,7 @@ func TestValidatePod(t *testing.T) {
|
||||
),
|
||||
},
|
||||
"too long AppArmor localhost profile": {
|
||||
expectedError: "Too long: may not be longer than 4095",
|
||||
expectedError: "Too long: may not be more than 4095 bytes",
|
||||
spec: *podtest.MakePod("123",
|
||||
podtest.SetSecurityContext(&core.PodSecurityContext{
|
||||
AppArmorProfile: &core.AppArmorProfile{
|
||||
|
||||
Reference in New Issue
Block a user