Move field errors to pkg/util/fielderrors

Allows pkg/api to take a reference to labels.Selector and fields.Selector
This commit is contained in:
Clayton Coleman
2015-03-22 17:40:47 -04:00
parent ef758881d1
commit 65425f690c
21 changed files with 57 additions and 47 deletions

View File

@@ -20,6 +20,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
)
// RESTCreateStrategy defines the minimum validation, accepted input, and
@@ -38,7 +39,7 @@ type RESTCreateStrategy interface {
ResetBeforeCreate(obj runtime.Object)
// Validate is invoked after default fields in the object have been filled in before
// the object is persisted.
Validate(obj runtime.Object) errors.ValidationErrorList
Validate(obj runtime.Object) fielderrors.ValidationErrorList
}
// BeforeCreate ensures that common operations for all resources are performed on creation. It only returns

View File

@@ -18,9 +18,9 @@ package rest
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
)
// ObjectFunc is a function to act on a given object. An error may be returned
@@ -67,7 +67,7 @@ func (svcStrategy) ResetBeforeCreate(obj runtime.Object) {
}
// Validate validates a new service.
func (svcStrategy) Validate(obj runtime.Object) errors.ValidationErrorList {
func (svcStrategy) Validate(obj runtime.Object) fielderrors.ValidationErrorList {
service := obj.(*api.Service)
return validation.ValidateService(service)
}
@@ -76,7 +76,7 @@ func (svcStrategy) AllowCreateOnUpdate() bool {
return true
}
func (svcStrategy) ValidateUpdate(obj, old runtime.Object) errors.ValidationErrorList {
func (svcStrategy) ValidateUpdate(obj, old runtime.Object) fielderrors.ValidationErrorList {
return validation.ValidateServiceUpdate(old.(*api.Service), obj.(*api.Service))
}
@@ -103,7 +103,7 @@ func (nodeStrategy) ResetBeforeCreate(obj runtime.Object) {
}
// Validate validates a new node.
func (nodeStrategy) Validate(obj runtime.Object) errors.ValidationErrorList {
func (nodeStrategy) Validate(obj runtime.Object) fielderrors.ValidationErrorList {
node := obj.(*api.Node)
return validation.ValidateMinion(node)
}

View File

@@ -20,6 +20,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
)
// RESTUpdateStrategy defines the minimum validation, accepted input, and
@@ -34,7 +35,7 @@ type RESTUpdateStrategy interface {
AllowCreateOnUpdate() bool
// ValidateUpdate is invoked after default fields in the object have been filled in before
// the object is persisted.
ValidateUpdate(obj, old runtime.Object) errors.ValidationErrorList
ValidateUpdate(obj, old runtime.Object) fielderrors.ValidationErrorList
}
// BeforeUpdate ensures that common operations for all resources are performed on update. It only returns