mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Move FieldPath and errors to a sub-package
This makes the naming and reading a lot simpler.
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/errors"
|
||||
"k8s.io/kubernetes/pkg/api/validation"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
utilvalidation "k8s.io/kubernetes/pkg/util/validation"
|
||||
"k8s.io/kubernetes/pkg/util/validation/field"
|
||||
)
|
||||
|
||||
// RESTCreateStrategy defines the minimum validation, accepted input, and
|
||||
@@ -42,7 +42,7 @@ type RESTCreateStrategy interface {
|
||||
PrepareForCreate(obj runtime.Object)
|
||||
// Validate is invoked after default fields in the object have been filled in before
|
||||
// the object is persisted. This method should not mutate the object.
|
||||
Validate(ctx api.Context, obj runtime.Object) utilvalidation.ErrorList
|
||||
Validate(ctx api.Context, obj runtime.Object) field.ErrorList
|
||||
// Canonicalize is invoked after validation has succeeded but before the
|
||||
// object has been persisted. This method may mutate the object.
|
||||
Canonicalize(obj runtime.Object)
|
||||
@@ -77,7 +77,7 @@ func BeforeCreate(strategy RESTCreateStrategy, ctx api.Context, obj runtime.Obje
|
||||
// Custom validation (including name validation) passed
|
||||
// Now run common validation on object meta
|
||||
// Do this *after* custom validation so that specific error messages are shown whenever possible
|
||||
if errs := validation.ValidateObjectMeta(objectMeta, strategy.NamespaceScoped(), validation.ValidatePathSegmentName, utilvalidation.NewFieldPath("metadata")); len(errs) > 0 {
|
||||
if errs := validation.ValidateObjectMeta(objectMeta, strategy.NamespaceScoped(), validation.ValidatePathSegmentName, field.NewPath("metadata")); len(errs) > 0 {
|
||||
return errors.NewInvalid(kind, objectMeta.Name, errs)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user