mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 14:45:28 +00:00
Add validation error explanation for long annotations.
This commit is contained in:
@@ -92,7 +92,7 @@ var _ error = &ValidationError{}
|
||||
func (v *ValidationError) Error() string {
|
||||
var s string
|
||||
switch v.Type {
|
||||
case ValidationErrorTypeRequired:
|
||||
case ValidationErrorTypeRequired, ValidationErrorTypeTooLong:
|
||||
s = spew.Sprintf("%s: %s", v.Field, v.Type)
|
||||
default:
|
||||
s = spew.Sprintf("%s: %s '%+v'", v.Field, v.Type, v.BadValue)
|
||||
@@ -133,8 +133,8 @@ func NewFieldNotFound(field string, value interface{}) *ValidationError {
|
||||
return &ValidationError{ValidationErrorTypeNotFound, field, value, ""}
|
||||
}
|
||||
|
||||
func NewFieldTooLong(field string, value interface{}) *ValidationError {
|
||||
return &ValidationError{ValidationErrorTypeTooLong, field, value, ""}
|
||||
func NewFieldTooLong(field string, value interface{}, maxLength int) *ValidationError {
|
||||
return &ValidationError{ValidationErrorTypeTooLong, field, value, fmt.Sprintf("must have at most %d characters", maxLength)}
|
||||
}
|
||||
|
||||
type ValidationErrorList []error
|
||||
|
@@ -33,11 +33,6 @@ func IsValidLabelValue(value string) bool {
|
||||
return (len(value) <= LabelValueMaxLength && labelValueRegexp.MatchString(value))
|
||||
}
|
||||
|
||||
// Annotation values are opaque.
|
||||
func IsValidAnnotationValue(value string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
const QualifiedNameFmt string = "(" + qnameTokenFmt + "/)?" + qnameTokenFmt
|
||||
const QualifiedNameMaxLength int = 253
|
||||
|
||||
|
Reference in New Issue
Block a user