mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Loosen label and annotation validation and related tests
This commit is contained in:
@@ -52,6 +52,8 @@ const (
|
||||
// values which would be accepted by some api instances, but which would invoke behavior
|
||||
// not permitted by this api instance (such as due to stricter security policy).
|
||||
ValidationErrorTypeForbidden ValidationErrorType = "FieldValueForbidden"
|
||||
// ValidationErrorTypeTooLong is used to report that given value is too long.
|
||||
ValidationErrorTypeTooLong ValidationErrorType = "FieldValueTooLong"
|
||||
)
|
||||
|
||||
// String converts a ValidationErrorType into its corresponding error message.
|
||||
@@ -69,6 +71,8 @@ func (t ValidationErrorType) String() string {
|
||||
return "unsupported value"
|
||||
case ValidationErrorTypeForbidden:
|
||||
return "forbidden"
|
||||
case ValidationErrorTypeTooLong:
|
||||
return "too long"
|
||||
default:
|
||||
glog.Errorf("unrecognized validation type: %#v", t)
|
||||
return ""
|
||||
@@ -130,6 +134,10 @@ func NewFieldNotFound(field string, value interface{}) *ValidationError {
|
||||
return &ValidationError{ValidationErrorTypeNotFound, field, value, ""}
|
||||
}
|
||||
|
||||
func NewFieldTooLong(field string, value interface{}) *ValidationError {
|
||||
return &ValidationError{ValidationErrorTypeTooLong, field, value, ""}
|
||||
}
|
||||
|
||||
type ValidationErrorList []error
|
||||
|
||||
// Prefix adds a prefix to the Field of every ValidationError in the list.
|
||||
|
||||
Reference in New Issue
Block a user