Merge pull request #54484 from sttts/sttts-split-psp
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. admission: wire through validating-only admission Based on https://github.com/kubernetes/kubernetes/pull/54232. This is important and required for beta because it affects the shape of the webhook admission plugins that are going to be produced and is needed to make sure that our existing chain continues to properly verify and protect the API objects based on their final state after webhook admission mutators run. We discussed this in the October 11 API machinery call with @erictune and @caesarxuchao and we agreed to do this as a requirement for beta. See this part of the recording: https://www.youtube.com/watch?v=mrgDPHyr4VY#t=325 .
This commit is contained in:
@@ -34,13 +34,13 @@ import (
|
||||
// WantsInternalKubeClientSet defines a function which sets ClientSet for admission plugins that need it
|
||||
type WantsInternalKubeClientSet interface {
|
||||
SetInternalKubeClientSet(internalclientset.Interface)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
||||
// WantsInternalKubeInformerFactory defines a function which sets InformerFactory for admission plugins that need it
|
||||
type WantsInternalKubeInformerFactory interface {
|
||||
SetInternalKubeInformerFactory(informers.SharedInformerFactory)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
||||
// WantsCloudConfig defines a function which sets CloudConfig for admission plugins that need it.
|
||||
@@ -56,7 +56,7 @@ type WantsRESTMapper interface {
|
||||
// WantsQuotaConfiguration defines a function which sets quota configuration for admission plugins that need it.
|
||||
type WantsQuotaConfiguration interface {
|
||||
SetQuotaConfiguration(quota.Configuration)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
||||
// WantsServiceResolver defines a fuction that accepts a ServiceResolver for
|
||||
@@ -75,7 +75,7 @@ type ServiceResolver interface {
|
||||
// to allow the apiserver to control what is returned as auth info
|
||||
type WantsAuthenticationInfoResolverWrapper interface {
|
||||
SetAuthenticationInfoResolverWrapper(webhook.AuthenticationInfoResolverWrapper)
|
||||
admission.Validator
|
||||
admission.InitializationValidator
|
||||
}
|
||||
|
||||
type PluginInitializer struct {
|
||||
|
||||
@@ -21,6 +21,7 @@ go_library(
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/storage:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/retry:go_default_library",
|
||||
],
|
||||
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
kruntime "k8s.io/apimachinery/pkg/runtime"
|
||||
apirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/apiserver/pkg/storage"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/endpoints"
|
||||
@@ -220,7 +221,7 @@ func (r *leaseEndpointReconciler) doReconcile(serviceName string, endpointPorts
|
||||
}
|
||||
|
||||
glog.Warningf("Resetting endpoints for master service %q to %v", serviceName, masterIPs)
|
||||
return r.endpointRegistry.UpdateEndpoints(ctx, e)
|
||||
return r.endpointRegistry.UpdateEndpoints(ctx, e, rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
}
|
||||
|
||||
// checkEndpointSubsetFormatWithLease determines if the endpoint is in the
|
||||
|
||||
@@ -33,8 +33,8 @@ type Registry interface {
|
||||
ListStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*apps.StatefulSetList, error)
|
||||
WatchStatefulSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
GetStatefulSet(ctx genericapirequest.Context, statefulSetID string, options *metav1.GetOptions) (*apps.StatefulSet, error)
|
||||
CreateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet) (*apps.StatefulSet, error)
|
||||
UpdateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet) (*apps.StatefulSet, error)
|
||||
CreateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc) (*apps.StatefulSet, error)
|
||||
UpdateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*apps.StatefulSet, error)
|
||||
DeleteStatefulSet(ctx genericapirequest.Context, statefulSetID string) error
|
||||
}
|
||||
|
||||
@@ -72,16 +72,16 @@ func (s *storage) GetStatefulSet(ctx genericapirequest.Context, statefulSetID st
|
||||
return obj.(*apps.StatefulSet), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet) (*apps.StatefulSet, error) {
|
||||
obj, err := s.Create(ctx, statefulSet, false)
|
||||
func (s *storage) CreateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc) (*apps.StatefulSet, error) {
|
||||
obj, err := s.Create(ctx, statefulSet, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*apps.StatefulSet), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet) (*apps.StatefulSet, error) {
|
||||
obj, _, err := s.Update(ctx, statefulSet.Name, rest.DefaultUpdatedObjectInfo(statefulSet))
|
||||
func (s *storage) UpdateStatefulSet(ctx genericapirequest.Context, statefulSet *apps.StatefulSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*apps.StatefulSet, error) {
|
||||
obj, _, err := s.Update(ctx, statefulSet.Name, rest.DefaultUpdatedObjectInfo(statefulSet), createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
// Implement ShortNamesProvider
|
||||
@@ -156,7 +156,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
|
||||
return scale, err
|
||||
}
|
||||
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
ss, err := r.registry.GetStatefulSet(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -185,7 +185,7 @@ func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo r
|
||||
|
||||
ss.Spec.Replicas = scale.Spec.Replicas
|
||||
ss.ResourceVersion = scale.ResourceVersion
|
||||
ss, err = r.registry.UpdateStatefulSet(ctx, ss)
|
||||
ss, err = r.registry.UpdateStatefulSet(ctx, ss, createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func newStorage(t *testing.T) (StatefulSetStorage, *etcdtesting.EtcdTestServer)
|
||||
// createStatefulSet is a helper function that returns a StatefulSet with the updated resource version.
|
||||
func createStatefulSet(storage *REST, ps apps.StatefulSet, t *testing.T) (apps.StatefulSet, error) {
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), ps.Namespace)
|
||||
obj, err := storage.Create(ctx, &ps, false)
|
||||
obj, err := storage.Create(ctx, &ps, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create StatefulSet, %v", err)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func TestStatusUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Status.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Status.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
obj, err := storage.StatefulSet.Get(ctx, "foo", &metav1.GetOptions{})
|
||||
@@ -274,7 +274,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("error updating scale %v: %v", update, err)
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
update.ResourceVersion = sts.ResourceVersion
|
||||
update.Spec.Replicas = 15
|
||||
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil && !errors.IsConflict(err) {
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil && !errors.IsConflict(err) {
|
||||
t.Fatalf("unexpected error, expecting an update conflict but got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ go_library(
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authentication/authenticator:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/authentication/authenticator"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/authentication"
|
||||
)
|
||||
|
||||
@@ -39,7 +40,7 @@ func (r *REST) New() runtime.Object {
|
||||
return &authentication.TokenReview{}
|
||||
}
|
||||
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
tokenReview, ok := obj.(*authentication.TokenReview)
|
||||
if !ok {
|
||||
return nil, apierrors.NewBadRequest(fmt.Sprintf("not a TokenReview: %#v", obj))
|
||||
|
||||
@@ -17,6 +17,7 @@ go_library(
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
|
||||
authorizationvalidation "k8s.io/kubernetes/pkg/apis/authorization/validation"
|
||||
authorizationutil "k8s.io/kubernetes/pkg/registry/authorization/util"
|
||||
@@ -40,7 +41,7 @@ func (r *REST) New() runtime.Object {
|
||||
return &authorizationapi.LocalSubjectAccessReview{}
|
||||
}
|
||||
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
localSubjectAccessReview, ok := obj.(*authorizationapi.LocalSubjectAccessReview)
|
||||
if !ok {
|
||||
return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a LocaLocalSubjectAccessReview: %#v", obj))
|
||||
|
||||
@@ -17,6 +17,7 @@ go_library(
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
|
||||
authorizationvalidation "k8s.io/kubernetes/pkg/apis/authorization/validation"
|
||||
authorizationutil "k8s.io/kubernetes/pkg/registry/authorization/util"
|
||||
@@ -40,7 +41,7 @@ func (r *REST) New() runtime.Object {
|
||||
return &authorizationapi.SelfSubjectAccessReview{}
|
||||
}
|
||||
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
selfSAR, ok := obj.(*authorizationapi.SelfSubjectAccessReview)
|
||||
if !ok {
|
||||
return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectAccessReview: %#v", obj))
|
||||
|
||||
@@ -11,6 +11,7 @@ go_library(
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
|
||||
)
|
||||
|
||||
@@ -42,7 +43,7 @@ func (r *REST) New() runtime.Object {
|
||||
}
|
||||
|
||||
// Create attempts to get self subject rules in specific namespace.
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
selfSRR, ok := obj.(*authorizationapi.SelfSubjectRulesReview)
|
||||
if !ok {
|
||||
return nil, apierrors.NewBadRequest(fmt.Sprintf("not a SelfSubjectRulesReview: %#v", obj))
|
||||
|
||||
@@ -18,6 +18,7 @@ go_library(
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -44,5 +45,6 @@ go_test(
|
||||
"//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
|
||||
authorizationvalidation "k8s.io/kubernetes/pkg/apis/authorization/validation"
|
||||
authorizationutil "k8s.io/kubernetes/pkg/registry/authorization/util"
|
||||
@@ -40,7 +41,7 @@ func (r *REST) New() runtime.Object {
|
||||
return &authorizationapi.SubjectAccessReview{}
|
||||
}
|
||||
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
subjectAccessReview, ok := obj.(*authorizationapi.SubjectAccessReview)
|
||||
if !ok {
|
||||
return nil, kapierrors.NewBadRequest(fmt.Sprintf("not a SubjectAccessReview: %#v", obj))
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
authorizationapi "k8s.io/kubernetes/pkg/apis/authorization"
|
||||
)
|
||||
|
||||
@@ -174,9 +175,9 @@ func TestCreate(t *testing.T) {
|
||||
reason: tc.reason,
|
||||
err: tc.err,
|
||||
}
|
||||
rest := NewREST(auth)
|
||||
storage := NewREST(auth)
|
||||
|
||||
result, err := rest.Create(genericapirequest.NewContext(), &authorizationapi.SubjectAccessReview{Spec: tc.spec}, false)
|
||||
result, err := storage.Create(genericapirequest.NewContext(), &authorizationapi.SubjectAccessReview{Spec: tc.spec}, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
if tc.expectedErr != "" {
|
||||
if !strings.Contains(err.Error(), tc.expectedErr) {
|
||||
|
||||
@@ -83,6 +83,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -81,6 +81,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -98,6 +98,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store CSRs.
|
||||
type Registry interface {
|
||||
ListCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*certificates.CertificateSigningRequestList, error)
|
||||
CreateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest) error
|
||||
UpdateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest) error
|
||||
CreateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetCSR(ctx genericapirequest.Context, csrID string, options *metav1.GetOptions) (*certificates.CertificateSigningRequest, error)
|
||||
DeleteCSR(ctx genericapirequest.Context, csrID string) error
|
||||
WatchCSRs(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,13 @@ func (s *storage) ListCSRs(ctx genericapirequest.Context, options *metainternalv
|
||||
return obj.(*certificates.CertificateSigningRequestList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest) error {
|
||||
_, err := s.Create(ctx, csr, false)
|
||||
func (s *storage) CreateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, csr, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest) error {
|
||||
_, _, err := s.Update(ctx, csr.Name, rest.DefaultUpdatedObjectInfo(csr))
|
||||
func (s *storage) UpdateCSR(ctx genericapirequest.Context, csr *certificates.CertificateSigningRequest, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, csr.Name, rest.DefaultUpdatedObjectInfo(csr), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ func (r *StatusREST) New() runtime.Object {
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
// ApprovalREST implements the REST endpoint for changing the approval state of a CSR.
|
||||
@@ -92,6 +92,6 @@ func (r *ApprovalREST) New() runtime.Object {
|
||||
}
|
||||
|
||||
// Update alters the approval subset of an object.
|
||||
func (r *ApprovalREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *ApprovalREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ type Registry interface {
|
||||
ListConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ConfigMapList, error)
|
||||
WatchConfigMaps(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
GetConfigMap(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.ConfigMap, error)
|
||||
CreateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap) (*api.ConfigMap, error)
|
||||
UpdateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap) (*api.ConfigMap, error)
|
||||
CreateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc) (*api.ConfigMap, error)
|
||||
UpdateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ConfigMap, error)
|
||||
DeleteConfigMap(ctx genericapirequest.Context, name string) error
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ func (s *storage) GetConfigMap(ctx genericapirequest.Context, name string, optio
|
||||
return obj.(*api.ConfigMap), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
obj, err := s.Create(ctx, cfg, false)
|
||||
func (s *storage) CreateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc) (*api.ConfigMap, error) {
|
||||
obj, err := s.Create(ctx, cfg, createValidation, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,8 +77,8 @@ func (s *storage) CreateConfigMap(ctx genericapirequest.Context, cfg *api.Config
|
||||
return obj.(*api.ConfigMap), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
obj, _, err := s.Update(ctx, cfg.Name, rest.DefaultUpdatedObjectInfo(cfg))
|
||||
func (s *storage) UpdateConfigMap(ctx genericapirequest.Context, cfg *api.ConfigMap, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ConfigMap, error) {
|
||||
obj, _, err := s.Update(ctx, cfg.Name, rest.DefaultUpdatedObjectInfo(cfg), createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ type Registry interface {
|
||||
ListEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.EndpointsList, error)
|
||||
GetEndpoints(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Endpoints, error)
|
||||
WatchEndpoints(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
UpdateEndpoints(ctx genericapirequest.Context, e *api.Endpoints) error
|
||||
UpdateEndpoints(ctx genericapirequest.Context, e *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
DeleteEndpoints(ctx genericapirequest.Context, name string) error
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ func (s *storage) GetEndpoints(ctx genericapirequest.Context, name string, optio
|
||||
return obj.(*api.Endpoints), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateEndpoints(ctx genericapirequest.Context, endpoints *api.Endpoints) error {
|
||||
_, _, err := s.Update(ctx, endpoints.Name, rest.DefaultUpdatedObjectInfo(endpoints))
|
||||
func (s *storage) UpdateEndpoints(ctx genericapirequest.Context, endpoints *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, endpoints.Name, rest.DefaultUpdatedObjectInfo(endpoints), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ type Registry interface {
|
||||
ListNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NamespaceList, error)
|
||||
WatchNamespaces(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
GetNamespace(ctx genericapirequest.Context, namespaceID string, options *metav1.GetOptions) (*api.Namespace, error)
|
||||
CreateNamespace(ctx genericapirequest.Context, namespace *api.Namespace) error
|
||||
UpdateNamespace(ctx genericapirequest.Context, namespace *api.Namespace) error
|
||||
CreateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
DeleteNamespace(ctx genericapirequest.Context, namespaceID string) error
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@ func (s *storage) GetNamespace(ctx genericapirequest.Context, namespaceName stri
|
||||
return obj.(*api.Namespace), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateNamespace(ctx genericapirequest.Context, namespace *api.Namespace) error {
|
||||
_, err := s.Create(ctx, namespace, false)
|
||||
func (s *storage) CreateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, namespace, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateNamespace(ctx genericapirequest.Context, namespace *api.Namespace) error {
|
||||
_, _, err := s.Update(ctx, namespace.Name, rest.DefaultUpdatedObjectInfo(namespace))
|
||||
func (s *storage) UpdateNamespace(ctx genericapirequest.Context, namespace *api.Namespace, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, namespace.Name, rest.DefaultUpdatedObjectInfo(namespace), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ go_test(
|
||||
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/generic:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/registry/rest:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/storage/etcd/testing:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -89,12 +89,12 @@ func (r *REST) List(ctx genericapirequest.Context, options *metainternalversion.
|
||||
return r.store.List(ctx, options)
|
||||
}
|
||||
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
return r.store.Create(ctx, obj, includeUninitialized)
|
||||
func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
return r.store.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
func (r *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
func (r *REST) Get(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||
@@ -219,8 +219,8 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
func (r *FinalizeREST) New() runtime.Object {
|
||||
@@ -228,6 +228,6 @@ func (r *FinalizeREST) New() runtime.Object {
|
||||
}
|
||||
|
||||
// Update alters the status finalizers subset of an object.
|
||||
func (r *FinalizeREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *FinalizeREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/generic"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||
@@ -67,7 +68,7 @@ func TestCreateSetsFields(t *testing.T) {
|
||||
defer storage.store.DestroyFunc()
|
||||
namespace := validNewNamespace()
|
||||
ctx := genericapirequest.NewContext()
|
||||
_, err := storage.Create(ctx, namespace, false)
|
||||
_, err := storage.Create(ctx, namespace, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store node.
|
||||
type Registry interface {
|
||||
ListNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.NodeList, error)
|
||||
CreateNode(ctx genericapirequest.Context, node *api.Node) error
|
||||
UpdateNode(ctx genericapirequest.Context, node *api.Node) error
|
||||
CreateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetNode(ctx genericapirequest.Context, nodeID string, options *metav1.GetOptions) (*api.Node, error)
|
||||
DeleteNode(ctx genericapirequest.Context, nodeID string) error
|
||||
WatchNodes(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,13 @@ func (s *storage) ListNodes(ctx genericapirequest.Context, options *metainternal
|
||||
return obj.(*api.NodeList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateNode(ctx genericapirequest.Context, node *api.Node) error {
|
||||
_, err := s.Create(ctx, node, false)
|
||||
func (s *storage) CreateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, node, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateNode(ctx genericapirequest.Context, node *api.Node) error {
|
||||
_, _, err := s.Update(ctx, node.Name, rest.DefaultUpdatedObjectInfo(node))
|
||||
func (s *storage) UpdateNode(ctx genericapirequest.Context, node *api.Node, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, node.Name, rest.DefaultUpdatedObjectInfo(node), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
// NewStorage returns a NodeStorage object that will work against nodes.
|
||||
|
||||
@@ -78,6 +78,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ func TestUpdateStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
_, _, err = statusStorage.Update(ctx, pvIn.Name, rest.DefaultUpdatedObjectInfo(pvIn))
|
||||
_, _, err = statusStorage.Update(ctx, pvIn.Name, rest.DefaultUpdatedObjectInfo(pvIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -78,6 +78,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func TestUpdateStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
_, _, err = statusStorage.Update(ctx, pvc.Name, rest.DefaultUpdatedObjectInfo(pvc))
|
||||
_, _, err = statusStorage.Update(ctx, pvc.Name, rest.DefaultUpdatedObjectInfo(pvc), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func (r *EvictionREST) New() runtime.Object {
|
||||
}
|
||||
|
||||
// Create attempts to create a new eviction. That is, it tries to evict a pod.
|
||||
func (r *EvictionREST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (r *EvictionREST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
eviction := obj.(*policy.Eviction)
|
||||
|
||||
obj, err := r.store.Get(ctx, eviction.Name, &metav1.GetOptions{})
|
||||
|
||||
@@ -135,7 +135,7 @@ func (r *BindingREST) New() runtime.Object {
|
||||
var _ = rest.Creater(&BindingREST{})
|
||||
|
||||
// Create ensures a pod is bound to a specific host.
|
||||
func (r *BindingREST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (out runtime.Object, err error) {
|
||||
func (r *BindingREST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (out runtime.Object, err error) {
|
||||
binding := obj.(*api.Binding)
|
||||
|
||||
// TODO: move me to a binding strategy
|
||||
@@ -212,6 +212,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ func TestIgnoreDeleteNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
// create pod
|
||||
_, err = registry.Create(testContext, pod, false)
|
||||
_, err = registry.Create(testContext, pod, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
@@ -225,7 +225,7 @@ func TestCreateSetsFields(t *testing.T) {
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
pod := validNewPod()
|
||||
_, err := storage.Create(genericapirequest.NewDefaultContext(), pod, false)
|
||||
_, err := storage.Create(genericapirequest.NewDefaultContext(), pod, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -489,7 +489,7 @@ func TestEtcdCreate(t *testing.T) {
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
_, err := storage.Create(ctx, validNewPod(), false)
|
||||
_, err := storage.Create(ctx, validNewPod(), rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -498,7 +498,7 @@ func TestEtcdCreate(t *testing.T) {
|
||||
_, err = bindingStorage.Create(ctx, &api.Binding{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "foo"},
|
||||
Target: api.ObjectReference{Name: "machine"},
|
||||
}, false)
|
||||
}, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -524,7 +524,7 @@ func TestEtcdCreateBindingNoPod(t *testing.T) {
|
||||
_, err := bindingStorage.Create(ctx, &api.Binding{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "foo"},
|
||||
Target: api.ObjectReference{Name: "machine"},
|
||||
}, false)
|
||||
}, rest.ValidateAllObjectFunc, false)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected not-found-error but got nothing")
|
||||
}
|
||||
@@ -547,7 +547,7 @@ func TestEtcdCreateFailsWithoutNamespace(t *testing.T) {
|
||||
defer storage.Store.DestroyFunc()
|
||||
pod := validNewPod()
|
||||
pod.Namespace = ""
|
||||
_, err := storage.Create(genericapirequest.NewContext(), pod, false)
|
||||
_, err := storage.Create(genericapirequest.NewContext(), pod, rest.ValidateAllObjectFunc, false)
|
||||
// Accept "namespace" or "Namespace".
|
||||
if err == nil || !strings.Contains(err.Error(), "amespace") {
|
||||
t.Fatalf("expected error that namespace was missing from context, got: %v", err)
|
||||
@@ -559,7 +559,7 @@ func TestEtcdCreateWithContainersNotFound(t *testing.T) {
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
_, err := storage.Create(ctx, validNewPod(), false)
|
||||
_, err := storage.Create(ctx, validNewPod(), rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -572,7 +572,7 @@ func TestEtcdCreateWithContainersNotFound(t *testing.T) {
|
||||
Annotations: map[string]string{"label1": "value1"},
|
||||
},
|
||||
Target: api.ObjectReference{Name: "machine"},
|
||||
}, false)
|
||||
}, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -594,7 +594,7 @@ func TestEtcdCreateWithConflict(t *testing.T) {
|
||||
defer storage.Store.DestroyFunc()
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
|
||||
_, err := storage.Create(ctx, validNewPod(), false)
|
||||
_, err := storage.Create(ctx, validNewPod(), rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -608,12 +608,12 @@ func TestEtcdCreateWithConflict(t *testing.T) {
|
||||
},
|
||||
Target: api.ObjectReference{Name: "machine"},
|
||||
}
|
||||
_, err = bindingStorage.Create(ctx, &binding, false)
|
||||
_, err = bindingStorage.Create(ctx, &binding, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
_, err = bindingStorage.Create(ctx, &binding, false)
|
||||
_, err = bindingStorage.Create(ctx, &binding, rest.ValidateAllObjectFunc, false)
|
||||
if err == nil || !errors.IsConflict(err) {
|
||||
t.Fatalf("expected resource conflict error, not: %v", err)
|
||||
}
|
||||
@@ -624,7 +624,7 @@ func TestEtcdCreateWithExistingContainers(t *testing.T) {
|
||||
defer server.Terminate(t)
|
||||
defer storage.Store.DestroyFunc()
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
_, err := storage.Create(ctx, validNewPod(), false)
|
||||
_, err := storage.Create(ctx, validNewPod(), rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -633,7 +633,7 @@ func TestEtcdCreateWithExistingContainers(t *testing.T) {
|
||||
_, err = bindingStorage.Create(ctx, &api.Binding{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "foo"},
|
||||
Target: api.ObjectReference{Name: "machine"},
|
||||
}, false)
|
||||
}, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -683,10 +683,10 @@ func TestEtcdCreateBinding(t *testing.T) {
|
||||
for k, test := range testCases {
|
||||
storage, bindingStorage, _, server := newStorage(t)
|
||||
|
||||
if _, err := storage.Create(ctx, validNewPod(), false); err != nil {
|
||||
if _, err := storage.Create(ctx, validNewPod(), rest.ValidateAllObjectFunc, false); err != nil {
|
||||
t.Fatalf("%s: unexpected error: %v", k, err)
|
||||
}
|
||||
if _, err := bindingStorage.Create(ctx, &test.binding, false); !test.errOK(err) {
|
||||
if _, err := bindingStorage.Create(ctx, &test.binding, rest.ValidateAllObjectFunc, false); !test.errOK(err) {
|
||||
t.Errorf("%s: unexpected error: %v", k, err)
|
||||
} else if err == nil {
|
||||
// If bind succeeded, verify Host field in pod's Spec.
|
||||
@@ -712,7 +712,7 @@ func TestEtcdUpdateUninitialized(t *testing.T) {
|
||||
pod := validNewPod()
|
||||
// add pending initializers to the pod
|
||||
pod.ObjectMeta.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "init.k8s.io"}}}
|
||||
if _, err := storage.Create(ctx, pod, true); err != nil {
|
||||
if _, err := storage.Create(ctx, pod, rest.ValidateAllObjectFunc, true); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
podIn := *pod
|
||||
@@ -727,7 +727,7 @@ func TestEtcdUpdateUninitialized(t *testing.T) {
|
||||
})
|
||||
podIn.ObjectMeta.Initializers = nil
|
||||
|
||||
_, _, err := storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn))
|
||||
_, _, err := storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
@@ -754,7 +754,7 @@ func TestEtcdStatusUpdateUninitialized(t *testing.T) {
|
||||
pod := validNewPod()
|
||||
// add pending initializers to the pod
|
||||
pod.ObjectMeta.Initializers = &metav1.Initializers{Pending: []metav1.Initializer{{Name: "init.k8s.io"}}}
|
||||
if _, err := storage.Create(ctx, pod, true); err != nil {
|
||||
if _, err := storage.Create(ctx, pod, rest.ValidateAllObjectFunc, true); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
podIn := *pod
|
||||
@@ -762,7 +762,7 @@ func TestEtcdStatusUpdateUninitialized(t *testing.T) {
|
||||
podIn.Status.Phase = api.PodRunning
|
||||
podIn.ObjectMeta.Initializers = nil
|
||||
|
||||
_, _, err := statusStorage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn))
|
||||
_, _, err := statusStorage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
expected := "Forbidden: must not update status when the object is uninitialized"
|
||||
if err == nil {
|
||||
t.Fatalf("Unexpected no err, expected %q", expected)
|
||||
@@ -778,12 +778,12 @@ func TestEtcdUpdateNotScheduled(t *testing.T) {
|
||||
defer storage.Store.DestroyFunc()
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
|
||||
if _, err := storage.Create(ctx, validNewPod(), false); err != nil {
|
||||
if _, err := storage.Create(ctx, validNewPod(), rest.ValidateAllObjectFunc, false); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
podIn := validChangedPod()
|
||||
_, _, err := storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(podIn))
|
||||
_, _, err := storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
@@ -853,7 +853,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
|
||||
SchedulerName: api.DefaultSchedulerName,
|
||||
},
|
||||
}
|
||||
_, _, err = storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn))
|
||||
_, _, err = storage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
@@ -937,7 +937,7 @@ func TestEtcdUpdateStatus(t *testing.T) {
|
||||
expected.Labels = podIn.Labels
|
||||
expected.Status = podIn.Status
|
||||
|
||||
_, _, err = statusStorage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn))
|
||||
_, _, err = statusStorage.Update(ctx, podIn.Name, rest.DefaultUpdatedObjectInfo(&podIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ type Registry interface {
|
||||
ListControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ReplicationControllerList, error)
|
||||
WatchControllers(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
GetController(ctx genericapirequest.Context, controllerID string, options *metav1.GetOptions) (*api.ReplicationController, error)
|
||||
CreateController(ctx genericapirequest.Context, controller *api.ReplicationController) (*api.ReplicationController, error)
|
||||
UpdateController(ctx genericapirequest.Context, controller *api.ReplicationController) (*api.ReplicationController, error)
|
||||
CreateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc) (*api.ReplicationController, error)
|
||||
UpdateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ReplicationController, error)
|
||||
DeleteController(ctx genericapirequest.Context, controllerID string) error
|
||||
}
|
||||
|
||||
@@ -73,16 +73,16 @@ func (s *storage) GetController(ctx genericapirequest.Context, controllerID stri
|
||||
return obj.(*api.ReplicationController), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateController(ctx genericapirequest.Context, controller *api.ReplicationController) (*api.ReplicationController, error) {
|
||||
obj, err := s.Create(ctx, controller, false)
|
||||
func (s *storage) CreateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc) (*api.ReplicationController, error) {
|
||||
obj, err := s.Create(ctx, controller, createValidation, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*api.ReplicationController), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateController(ctx genericapirequest.Context, controller *api.ReplicationController) (*api.ReplicationController, error) {
|
||||
obj, _, err := s.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller))
|
||||
func (s *storage) UpdateController(ctx genericapirequest.Context, controller *api.ReplicationController, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.ReplicationController, error) {
|
||||
obj, _, err := s.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller), createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
type ScaleREST struct {
|
||||
@@ -153,13 +153,14 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
|
||||
return scaleFromRC(rc), nil
|
||||
}
|
||||
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
rc, err := r.registry.GetController(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, false, errors.NewNotFound(autoscaling.Resource("replicationcontrollers/scale"), name)
|
||||
}
|
||||
|
||||
oldScale := scaleFromRC(rc)
|
||||
// TODO: should this pass validation?
|
||||
obj, err := objInfo.UpdatedObject(ctx, oldScale)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -179,7 +180,7 @@ func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo r
|
||||
|
||||
rc.Spec.Replicas = scale.Spec.Replicas
|
||||
rc.ResourceVersion = scale.ResourceVersion
|
||||
rc, err = r.registry.UpdateController(ctx, rc)
|
||||
rc, err = r.registry.UpdateController(ctx, rc, createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func newStorage(t *testing.T) (ControllerStorage, *etcdtesting.EtcdTestServer) {
|
||||
// createController is a helper function that returns a controller with the updated resource version.
|
||||
func createController(storage *REST, rc api.ReplicationController, t *testing.T) (api.ReplicationController, error) {
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), rc.Namespace)
|
||||
obj, err := storage.Create(ctx, &rc, false)
|
||||
obj, err := storage.Create(ctx, &rc, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create controller, %v", err)
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func TestGenerationNumber(t *testing.T) {
|
||||
|
||||
// Updates to spec should increment the generation number
|
||||
controller.Spec.Replicas += 1
|
||||
storage.Controller.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller))
|
||||
storage.Controller.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func TestGenerationNumber(t *testing.T) {
|
||||
|
||||
// Updates to status should not increment either spec or status generation numbers
|
||||
controller.Status.Replicas += 1
|
||||
storage.Controller.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller))
|
||||
storage.Controller.Update(ctx, controller.Name, rest.DefaultUpdatedObjectInfo(controller), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -308,7 +308,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("error updating scale %v: %v", update, err)
|
||||
}
|
||||
obj, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{})
|
||||
@@ -323,7 +323,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
update.ResourceVersion = rc.ResourceVersion
|
||||
update.Spec.Replicas = 15
|
||||
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil && !errors.IsConflict(err) {
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil && !errors.IsConflict(err) {
|
||||
t.Fatalf("unexpected error, expecting an update conflict but got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ func TestCreateSetsFields(t *testing.T) {
|
||||
defer storage.Store.DestroyFunc()
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
resourcequota := validNewResourceQuota()
|
||||
_, err := storage.Create(genericapirequest.NewDefaultContext(), resourcequota, false)
|
||||
_, err := storage.Create(genericapirequest.NewDefaultContext(), resourcequota, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ func TestUpdateStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
_, _, err = status.Update(ctx, resourcequotaIn.Name, rest.DefaultUpdatedObjectInfo(resourcequotaIn))
|
||||
_, _, err = status.Update(ctx, resourcequotaIn.Name, rest.DefaultUpdatedObjectInfo(resourcequotaIn), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ type Registry interface {
|
||||
ListSecrets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.SecretList, error)
|
||||
WatchSecrets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
GetSecret(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Secret, error)
|
||||
CreateSecret(ctx genericapirequest.Context, Secret *api.Secret) (*api.Secret, error)
|
||||
UpdateSecret(ctx genericapirequest.Context, Secret *api.Secret) (*api.Secret, error)
|
||||
CreateSecret(ctx genericapirequest.Context, Secret *api.Secret, createValidation rest.ValidateObjectFunc) (*api.Secret, error)
|
||||
UpdateSecret(ctx genericapirequest.Context, Secret *api.Secret, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Secret, error)
|
||||
DeleteSecret(ctx genericapirequest.Context, name string) error
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@ func (s *storage) GetSecret(ctx genericapirequest.Context, name string, options
|
||||
return obj.(*api.Secret), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateSecret(ctx genericapirequest.Context, secret *api.Secret) (*api.Secret, error) {
|
||||
obj, err := s.Create(ctx, secret, false)
|
||||
func (s *storage) CreateSecret(ctx genericapirequest.Context, secret *api.Secret, createValidation rest.ValidateObjectFunc) (*api.Secret, error) {
|
||||
obj, err := s.Create(ctx, secret, createValidation, false)
|
||||
return obj.(*api.Secret), err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateSecret(ctx genericapirequest.Context, secret *api.Secret) (*api.Secret, error) {
|
||||
obj, _, err := s.Update(ctx, secret.Name, rest.DefaultUpdatedObjectInfo(secret))
|
||||
func (s *storage) UpdateSecret(ctx genericapirequest.Context, secret *api.Secret, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Secret, error) {
|
||||
obj, _, err := s.Update(ctx, secret.Name, rest.DefaultUpdatedObjectInfo(secret), createValidation, updateValidation)
|
||||
return obj.(*api.Secret), err
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ import (
|
||||
// Registry is an interface for things that know how to store services.
|
||||
type Registry interface {
|
||||
ListServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ServiceList, error)
|
||||
CreateService(ctx genericapirequest.Context, svc *api.Service) (*api.Service, error)
|
||||
CreateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error)
|
||||
GetService(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.Service, error)
|
||||
DeleteService(ctx genericapirequest.Context, name string) error
|
||||
UpdateService(ctx genericapirequest.Context, svc *api.Service) (*api.Service, error)
|
||||
UpdateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error)
|
||||
WatchServices(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
ExportService(ctx genericapirequest.Context, name string, options metav1.ExportOptions) (*api.Service, error)
|
||||
}
|
||||
@@ -57,8 +57,8 @@ func (s *storage) ListServices(ctx genericapirequest.Context, options *metainter
|
||||
return obj.(*api.ServiceList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateService(ctx genericapirequest.Context, svc *api.Service) (*api.Service, error) {
|
||||
obj, err := s.Create(ctx, svc, false)
|
||||
func (s *storage) CreateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) {
|
||||
obj, err := s.Create(ctx, svc, createValidation, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -78,8 +78,8 @@ func (s *storage) DeleteService(ctx genericapirequest.Context, name string) erro
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateService(ctx genericapirequest.Context, svc *api.Service) (*api.Service, error) {
|
||||
obj, _, err := s.Update(ctx, svc.Name, rest.DefaultUpdatedObjectInfo(svc))
|
||||
func (s *storage) UpdateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) {
|
||||
obj, _, err := s.Update(ctx, svc.Name, rest.DefaultUpdatedObjectInfo(svc), createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (rs *REST) Categories() []string {
|
||||
}
|
||||
|
||||
// TODO: implement includeUninitialized by refactoring this to move to store
|
||||
func (rs *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (rs *REST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
service := obj.(*api.Service)
|
||||
|
||||
if err := rest.BeforeCreate(Strategy, ctx, obj); err != nil {
|
||||
@@ -133,7 +133,7 @@ func (rs *REST) Create(ctx genericapirequest.Context, obj runtime.Object, includ
|
||||
}
|
||||
}
|
||||
|
||||
out, err := rs.registry.CreateService(ctx, service)
|
||||
out, err := rs.registry.CreateService(ctx, service, createValidation)
|
||||
if err != nil {
|
||||
err = rest.CheckGeneratedNameError(Strategy, err, service)
|
||||
}
|
||||
@@ -284,7 +284,7 @@ func (rs *REST) healthCheckNodePortUpdate(oldService, service *api.Service, node
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (rs *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (rs *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
oldService, err := rs.registry.GetService(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -360,7 +360,7 @@ func (rs *REST) Update(ctx genericapirequest.Context, name string, objInfo rest.
|
||||
}
|
||||
}
|
||||
|
||||
out, err := rs.registry.UpdateService(ctx, service)
|
||||
out, err := rs.registry.UpdateService(ctx, service, createValidation, updateValidation)
|
||||
if err == nil {
|
||||
el := nodePortOp.Commit()
|
||||
if el != nil {
|
||||
|
||||
@@ -111,7 +111,7 @@ func TestServiceRegistryCreate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
created_svc, err := storage.Create(ctx, svc, false)
|
||||
created_svc, err := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
@@ -235,7 +235,7 @@ func TestServiceRegistryCreateMultiNodePortsService(t *testing.T) {
|
||||
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
for _, test := range testCases {
|
||||
created_svc, err := storage.Create(ctx, test.svc, false)
|
||||
created_svc, err := storage.Create(ctx, test.svc, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func TestServiceStorageValidatesCreate(t *testing.T) {
|
||||
}
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
for _, failureCase := range failureCases {
|
||||
c, err := storage.Create(ctx, &failureCase, false)
|
||||
c, err := storage.Create(ctx, &failureCase, rest.ValidateAllObjectFunc, false)
|
||||
if c != nil {
|
||||
t.Errorf("Expected nil object")
|
||||
}
|
||||
@@ -334,7 +334,7 @@ func TestServiceRegistryUpdate(t *testing.T) {
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
}},
|
||||
},
|
||||
})
|
||||
}, rest.ValidateAllObjectFunc)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error: %v", err)
|
||||
@@ -353,7 +353,7 @@ func TestServiceRegistryUpdate(t *testing.T) {
|
||||
TargetPort: intstr.FromInt(6502),
|
||||
}},
|
||||
},
|
||||
}))
|
||||
}), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Fatalf("Expected no error: %v", err)
|
||||
}
|
||||
@@ -384,7 +384,7 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
|
||||
Protocol: api.ProtocolTCP,
|
||||
}},
|
||||
},
|
||||
})
|
||||
}, rest.ValidateAllObjectFunc)
|
||||
failureCases := map[string]api.Service{
|
||||
"empty ID": {
|
||||
ObjectMeta: metav1.ObjectMeta{Name: ""},
|
||||
@@ -414,7 +414,7 @@ func TestServiceStorageValidatesUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, failureCase := range failureCases {
|
||||
c, created, err := storage.Update(ctx, failureCase.Name, rest.DefaultUpdatedObjectInfo(&failureCase))
|
||||
c, created, err := storage.Update(ctx, failureCase.Name, rest.DefaultUpdatedObjectInfo(&failureCase), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if c != nil || created {
|
||||
t.Errorf("Expected nil object or created false")
|
||||
}
|
||||
@@ -440,7 +440,7 @@ func TestServiceRegistryExternalService(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
}
|
||||
_, err := storage.Create(ctx, svc, false)
|
||||
_, err := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create service: %#v", err)
|
||||
}
|
||||
@@ -477,7 +477,7 @@ func TestServiceRegistryDelete(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
}
|
||||
registry.CreateService(ctx, svc)
|
||||
registry.CreateService(ctx, svc, rest.ValidateAllObjectFunc)
|
||||
storage.Delete(ctx, svc.Name)
|
||||
if e, a := "foo", registry.DeletedID; e != a {
|
||||
t.Errorf("Expected %v, but got %v", e, a)
|
||||
@@ -499,7 +499,7 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
}
|
||||
registry.CreateService(ctx, svc)
|
||||
registry.CreateService(ctx, svc, rest.ValidateAllObjectFunc)
|
||||
storage.Delete(ctx, svc.Name)
|
||||
if e, a := "foo", registry.DeletedID; e != a {
|
||||
t.Errorf("Expected %v, but got %v", e, a)
|
||||
@@ -524,14 +524,14 @@ func TestServiceRegistryUpdateExternalService(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
}
|
||||
if _, err := storage.Create(ctx, svc1, false); err != nil {
|
||||
if _, err := storage.Create(ctx, svc1, rest.ValidateAllObjectFunc, false); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// Modify load balancer to be external.
|
||||
svc2 := svc1.DeepCopy()
|
||||
svc2.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
if _, _, err := storage.Update(ctx, svc2.Name, rest.DefaultUpdatedObjectInfo(svc2)); err != nil {
|
||||
if _, _, err := storage.Update(ctx, svc2.Name, rest.DefaultUpdatedObjectInfo(svc2), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
defer releaseServiceNodePorts(t, ctx, svc2.Name, storage, registry)
|
||||
@@ -539,7 +539,7 @@ func TestServiceRegistryUpdateExternalService(t *testing.T) {
|
||||
// Change port.
|
||||
svc3 := svc2.DeepCopy()
|
||||
svc3.Spec.Ports[0].Port = 6504
|
||||
if _, _, err := storage.Update(ctx, svc3.Name, rest.DefaultUpdatedObjectInfo(svc3)); err != nil {
|
||||
if _, _, err := storage.Update(ctx, svc3.Name, rest.DefaultUpdatedObjectInfo(svc3), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,7 @@ func TestServiceRegistryUpdateMultiPortExternalService(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
}
|
||||
if _, err := storage.Create(ctx, svc1, false); err != nil {
|
||||
if _, err := storage.Create(ctx, svc1, rest.ValidateAllObjectFunc, false); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
defer releaseServiceNodePorts(t, ctx, svc1.Name, storage, registry)
|
||||
@@ -576,7 +576,7 @@ func TestServiceRegistryUpdateMultiPortExternalService(t *testing.T) {
|
||||
// Modify ports
|
||||
svc2 := svc1.DeepCopy()
|
||||
svc2.Spec.Ports[1].Port = 8088
|
||||
if _, _, err := storage.Update(ctx, svc2.Name, rest.DefaultUpdatedObjectInfo(svc2)); err != nil {
|
||||
if _, _, err := storage.Update(ctx, svc2.Name, rest.DefaultUpdatedObjectInfo(svc2), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -589,7 +589,7 @@ func TestServiceRegistryGet(t *testing.T) {
|
||||
Spec: api.ServiceSpec{
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
})
|
||||
}, rest.ValidateAllObjectFunc)
|
||||
storage.Get(ctx, "foo", &metav1.GetOptions{})
|
||||
if e, a := "foo", registry.GottenID; e != a {
|
||||
t.Errorf("Expected %v, but got %v", e, a)
|
||||
@@ -642,7 +642,7 @@ func TestServiceRegistryResourceLocation(t *testing.T) {
|
||||
{Name: "", Port: 93, TargetPort: intstr.FromInt(80)},
|
||||
},
|
||||
},
|
||||
})
|
||||
}, rest.ValidateAllObjectFunc)
|
||||
redirector := rest.Redirector(storage)
|
||||
|
||||
// Test a simple id.
|
||||
@@ -725,13 +725,13 @@ func TestServiceRegistryList(t *testing.T) {
|
||||
Spec: api.ServiceSpec{
|
||||
Selector: map[string]string{"bar": "baz"},
|
||||
},
|
||||
})
|
||||
}, rest.ValidateAllObjectFunc)
|
||||
registry.CreateService(ctx, &api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo2", Namespace: metav1.NamespaceDefault},
|
||||
Spec: api.ServiceSpec{
|
||||
Selector: map[string]string{"bar2": "baz2"},
|
||||
},
|
||||
})
|
||||
}, rest.ValidateAllObjectFunc)
|
||||
registry.List.ResourceVersion = "1"
|
||||
s, _ := storage.List(ctx, nil)
|
||||
sl := s.(*api.ServiceList)
|
||||
@@ -766,7 +766,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
created_svc1, _ := storage.Create(ctx, svc1, false)
|
||||
created_svc1, _ := storage.Create(ctx, svc1, rest.ValidateAllObjectFunc, false)
|
||||
created_service_1 := created_svc1.(*api.Service)
|
||||
if created_service_1.Name != "foo" {
|
||||
t.Errorf("Expected foo, but got %v", created_service_1.Name)
|
||||
@@ -788,7 +788,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
|
||||
}},
|
||||
}}
|
||||
ctx = genericapirequest.NewDefaultContext()
|
||||
created_svc2, _ := storage.Create(ctx, svc2, false)
|
||||
created_svc2, _ := storage.Create(ctx, svc2, rest.ValidateAllObjectFunc, false)
|
||||
created_service_2 := created_svc2.(*api.Service)
|
||||
if created_service_2.Name != "bar" {
|
||||
t.Errorf("Expected bar, but got %v", created_service_2.Name)
|
||||
@@ -821,7 +821,7 @@ func TestServiceRegistryIPAllocation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
ctx = genericapirequest.NewDefaultContext()
|
||||
created_svc3, err := storage.Create(ctx, svc3, false)
|
||||
created_svc3, err := storage.Create(ctx, svc3, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -848,7 +848,7 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
created_svc1, _ := storage.Create(ctx, svc1, false)
|
||||
created_svc1, _ := storage.Create(ctx, svc1, rest.ValidateAllObjectFunc, false)
|
||||
created_service_1 := created_svc1.(*api.Service)
|
||||
if created_service_1.Name != "foo" {
|
||||
t.Errorf("Expected foo, but got %v", created_service_1.Name)
|
||||
@@ -876,7 +876,7 @@ func TestServiceRegistryIPReallocation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
ctx = genericapirequest.NewDefaultContext()
|
||||
created_svc2, _ := storage.Create(ctx, svc2, false)
|
||||
created_svc2, _ := storage.Create(ctx, svc2, rest.ValidateAllObjectFunc, false)
|
||||
created_service_2 := created_svc2.(*api.Service)
|
||||
if created_service_2.Name != "bar" {
|
||||
t.Errorf("Expected bar, but got %v", created_service_2.Name)
|
||||
@@ -903,7 +903,7 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
created_svc, _ := storage.Create(ctx, svc, false)
|
||||
created_svc, _ := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
created_service := created_svc.(*api.Service)
|
||||
if created_service.Spec.Ports[0].Port != 6502 {
|
||||
t.Errorf("Expected port 6502, but got %v", created_service.Spec.Ports[0].Port)
|
||||
@@ -915,7 +915,7 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
|
||||
update := created_service.DeepCopy()
|
||||
update.Spec.Ports[0].Port = 6503
|
||||
|
||||
updated_svc, _, _ := storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(update))
|
||||
updated_svc, _, _ := storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
updated_service := updated_svc.(*api.Service)
|
||||
if updated_service.Spec.Ports[0].Port != 6503 {
|
||||
t.Errorf("Expected port 6503, but got %v", updated_service.Spec.Ports[0].Port)
|
||||
@@ -934,7 +934,7 @@ func TestServiceRegistryIPUpdate(t *testing.T) {
|
||||
update.Spec.Ports[0].Port = 6503
|
||||
update.Spec.ClusterIP = testIP // Error: Cluster IP is immutable
|
||||
|
||||
_, _, err := storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(update))
|
||||
_, _, err := storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err == nil || !errors.IsInvalid(err) {
|
||||
t.Errorf("Unexpected error type: %v", err)
|
||||
}
|
||||
@@ -957,7 +957,7 @@ func TestServiceRegistryIPLoadBalancer(t *testing.T) {
|
||||
},
|
||||
}
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
created_svc, err := storage.Create(ctx, svc, false)
|
||||
created_svc, err := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
if created_svc == nil || err != nil {
|
||||
t.Errorf("Unexpected failure creating service %v", err)
|
||||
}
|
||||
@@ -973,7 +973,7 @@ func TestServiceRegistryIPLoadBalancer(t *testing.T) {
|
||||
|
||||
update := created_service.DeepCopy()
|
||||
|
||||
_, _, err = storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(update))
|
||||
_, _, err = storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error %v", err)
|
||||
}
|
||||
@@ -986,7 +986,7 @@ func TestUpdateServiceWithConflictingNamespace(t *testing.T) {
|
||||
}
|
||||
|
||||
ctx := genericapirequest.NewDefaultContext()
|
||||
obj, created, err := storage.Update(ctx, service.Name, rest.DefaultUpdatedObjectInfo(service))
|
||||
obj, created, err := storage.Update(ctx, service.Name, rest.DefaultUpdatedObjectInfo(service), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if obj != nil || created {
|
||||
t.Error("Expected a nil object, but we got a value or created was true")
|
||||
}
|
||||
@@ -1016,7 +1016,7 @@ func TestServiceRegistryExternalTrafficHealthCheckNodePortAllocation(t *testing.
|
||||
ExternalTrafficPolicy: api.ServiceExternalTrafficPolicyTypeLocal,
|
||||
},
|
||||
}
|
||||
created_svc, err := storage.Create(ctx, svc, false)
|
||||
created_svc, err := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
if created_svc == nil || err != nil {
|
||||
t.Errorf("Unexpected failure creating service %v", err)
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ func TestServiceRegistryExternalTrafficHealthCheckNodePortUserAllocation(t *test
|
||||
HealthCheckNodePort: randomNodePort,
|
||||
},
|
||||
}
|
||||
created_svc, err := storage.Create(ctx, svc, false)
|
||||
created_svc, err := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
if created_svc == nil || err != nil {
|
||||
t.Fatalf("Unexpected failure creating service :%v", err)
|
||||
}
|
||||
@@ -1098,7 +1098,7 @@ func TestServiceRegistryExternalTrafficHealthCheckNodePortNegative(t *testing.T)
|
||||
HealthCheckNodePort: int32(-1),
|
||||
},
|
||||
}
|
||||
created_svc, err := storage.Create(ctx, svc, false)
|
||||
created_svc, err := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
if created_svc == nil || err != nil {
|
||||
return
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ func TestServiceRegistryExternalTrafficGlobal(t *testing.T) {
|
||||
ExternalTrafficPolicy: api.ServiceExternalTrafficPolicyTypeCluster,
|
||||
},
|
||||
}
|
||||
created_svc, err := storage.Create(ctx, svc, false)
|
||||
created_svc, err := storage.Create(ctx, svc, rest.ValidateAllObjectFunc, false)
|
||||
if created_svc == nil || err != nil {
|
||||
t.Errorf("Unexpected failure creating service %v", err)
|
||||
}
|
||||
|
||||
@@ -89,6 +89,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ type Registry interface {
|
||||
ListServiceAccounts(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*api.ServiceAccountList, error)
|
||||
WatchServiceAccounts(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
GetServiceAccount(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*api.ServiceAccount, error)
|
||||
CreateServiceAccount(ctx genericapirequest.Context, ServiceAccount *api.ServiceAccount) error
|
||||
UpdateServiceAccount(ctx genericapirequest.Context, ServiceAccount *api.ServiceAccount) error
|
||||
CreateServiceAccount(ctx genericapirequest.Context, ServiceAccount *api.ServiceAccount, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateServiceAccount(ctx genericapirequest.Context, ServiceAccount *api.ServiceAccount, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
DeleteServiceAccount(ctx genericapirequest.Context, name string) error
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@ func (s *storage) GetServiceAccount(ctx genericapirequest.Context, name string,
|
||||
return obj.(*api.ServiceAccount), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateServiceAccount(ctx genericapirequest.Context, serviceAccount *api.ServiceAccount) error {
|
||||
_, err := s.Create(ctx, serviceAccount, false)
|
||||
func (s *storage) CreateServiceAccount(ctx genericapirequest.Context, serviceAccount *api.ServiceAccount, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, serviceAccount, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateServiceAccount(ctx genericapirequest.Context, serviceAccount *api.ServiceAccount) error {
|
||||
_, _, err := s.Update(ctx, serviceAccount.Name, rest.DefaultUpdatedObjectInfo(serviceAccount))
|
||||
func (s *storage) UpdateServiceAccount(ctx genericapirequest.Context, serviceAccount *api.ServiceAccount, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, serviceAccount.Name, rest.DefaultUpdatedObjectInfo(serviceAccount), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
|
||||
return scaleFromRC(rc), nil
|
||||
}
|
||||
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
rc, err := (*r.registry).GetController(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, false, errors.NewNotFound(extensions.Resource("replicationcontrollers/scale"), name)
|
||||
@@ -92,7 +92,7 @@ func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo r
|
||||
|
||||
rc.Spec.Replicas = scale.Spec.Replicas
|
||||
rc.ResourceVersion = scale.ResourceVersion
|
||||
rc, err = (*r.registry).UpdateController(ctx, rc)
|
||||
rc, err = (*r.registry).UpdateController(ctx, rc, createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, false, errors.NewConflict(extensions.Resource("replicationcontrollers/scale"), scale.Name, err)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
obj, err := storage.Get(ctx, "foo", &metav1.GetOptions{})
|
||||
|
||||
@@ -89,6 +89,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import (
|
||||
type Registry interface {
|
||||
ListDeployments(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.DeploymentList, error)
|
||||
GetDeployment(ctx genericapirequest.Context, deploymentID string, options *metav1.GetOptions) (*extensions.Deployment, error)
|
||||
CreateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
||||
UpdateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment) (*extensions.Deployment, error)
|
||||
CreateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error)
|
||||
UpdateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.Deployment, error)
|
||||
DeleteDeployment(ctx genericapirequest.Context, deploymentID string) error
|
||||
}
|
||||
|
||||
@@ -64,16 +64,16 @@ func (s *storage) GetDeployment(ctx genericapirequest.Context, deploymentID stri
|
||||
return obj.(*extensions.Deployment), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) {
|
||||
obj, err := s.Create(ctx, deployment, false)
|
||||
func (s *storage) CreateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc) (*extensions.Deployment, error) {
|
||||
obj, err := s.Create(ctx, deployment, createValidation, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*extensions.Deployment), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment) (*extensions.Deployment, error) {
|
||||
obj, _, err := s.Update(ctx, deployment.Name, rest.DefaultUpdatedObjectInfo(deployment))
|
||||
func (s *storage) UpdateDeployment(ctx genericapirequest.Context, deployment *extensions.Deployment, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.Deployment, error) {
|
||||
obj, _, err := s.Update(ctx, deployment.Name, rest.DefaultUpdatedObjectInfo(deployment), createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
// RollbackREST implements the REST endpoint for initiating the rollback of a deployment
|
||||
@@ -131,7 +131,7 @@ func (r *RollbackREST) New() runtime.Object {
|
||||
|
||||
var _ = rest.Creater(&RollbackREST{})
|
||||
|
||||
func (r *RollbackREST) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (r *RollbackREST) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
rollback, ok := obj.(*extensions.DeploymentRollback)
|
||||
if !ok {
|
||||
return nil, errors.NewBadRequest(fmt.Sprintf("not a DeploymentRollback: %#v", obj))
|
||||
@@ -227,7 +227,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
|
||||
return scale, nil
|
||||
}
|
||||
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
deployment, err := r.registry.GetDeployment(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, false, errors.NewNotFound(extensions.Resource("deployments/scale"), name)
|
||||
@@ -256,7 +256,7 @@ func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo r
|
||||
|
||||
deployment.Spec.Replicas = scale.Spec.Replicas
|
||||
deployment.ResourceVersion = scale.ResourceVersion
|
||||
deployment, err = r.registry.UpdateDeployment(ctx, deployment)
|
||||
deployment, err = r.registry.UpdateDeployment(ctx, deployment, createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("error updating scale %v: %v", update, err)
|
||||
}
|
||||
obj, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{})
|
||||
@@ -266,7 +266,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
update.ResourceVersion = deployment.ResourceVersion
|
||||
update.Spec.Replicas = 15
|
||||
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil && !errors.IsConflict(err) {
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil && !errors.IsConflict(err) {
|
||||
t.Fatalf("unexpected error, expecting an update conflict but got %v", err)
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,7 @@ func TestStatusUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Status.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Status.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
obj, err := storage.Deployment.Get(ctx, name, &metav1.GetOptions{})
|
||||
@@ -341,10 +341,10 @@ func TestEtcdCreateDeploymentRollback(t *testing.T) {
|
||||
storage, server := newStorage(t)
|
||||
rollbackStorage := storage.Rollback
|
||||
|
||||
if _, err := storage.Deployment.Create(ctx, validNewDeployment(), false); err != nil {
|
||||
if _, err := storage.Deployment.Create(ctx, validNewDeployment(), rest.ValidateAllObjectFunc, false); err != nil {
|
||||
t.Fatalf("%s: unexpected error: %v", k, err)
|
||||
}
|
||||
rollbackRespStatus, err := rollbackStorage.Create(ctx, &test.rollback, false)
|
||||
rollbackRespStatus, err := rollbackStorage.Create(ctx, &test.rollback, rest.ValidateAllObjectFunc, false)
|
||||
if !test.errOK(err) {
|
||||
t.Errorf("%s: unexpected error: %v", k, err)
|
||||
} else if err == nil {
|
||||
@@ -381,7 +381,7 @@ func TestEtcdCreateDeploymentRollbackNoDeployment(t *testing.T) {
|
||||
Name: name,
|
||||
UpdatedAnnotations: map[string]string{},
|
||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
||||
}, false)
|
||||
}, rest.ValidateAllObjectFunc, false)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected not-found-error but got nothing")
|
||||
}
|
||||
|
||||
@@ -81,6 +81,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ type Registry interface {
|
||||
ListReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*extensions.ReplicaSetList, error)
|
||||
WatchReplicaSets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
GetReplicaSet(ctx genericapirequest.Context, replicaSetID string, options *metav1.GetOptions) (*extensions.ReplicaSet, error)
|
||||
CreateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet) (*extensions.ReplicaSet, error)
|
||||
UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet) (*extensions.ReplicaSet, error)
|
||||
CreateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc) (*extensions.ReplicaSet, error)
|
||||
UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.ReplicaSet, error)
|
||||
DeleteReplicaSet(ctx genericapirequest.Context, replicaSetID string) error
|
||||
}
|
||||
|
||||
@@ -73,16 +73,16 @@ func (s *storage) GetReplicaSet(ctx genericapirequest.Context, replicaSetID stri
|
||||
return obj.(*extensions.ReplicaSet), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet) (*extensions.ReplicaSet, error) {
|
||||
obj, err := s.Create(ctx, replicaSet, false)
|
||||
func (s *storage) CreateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc) (*extensions.ReplicaSet, error) {
|
||||
obj, err := s.Create(ctx, replicaSet, createValidation, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*extensions.ReplicaSet), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet) (*extensions.ReplicaSet, error) {
|
||||
obj, _, err := s.Update(ctx, replicaSet.Name, rest.DefaultUpdatedObjectInfo(replicaSet))
|
||||
func (s *storage) UpdateReplicaSet(ctx genericapirequest.Context, replicaSet *extensions.ReplicaSet, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*extensions.ReplicaSet, error) {
|
||||
obj, _, err := s.Update(ctx, replicaSet.Name, rest.DefaultUpdatedObjectInfo(replicaSet), createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
type ScaleREST struct {
|
||||
@@ -161,7 +161,7 @@ func (r *ScaleREST) Get(ctx genericapirequest.Context, name string, options *met
|
||||
return scale, err
|
||||
}
|
||||
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
rs, err := r.registry.GetReplicaSet(ctx, name, &metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, false, errors.NewNotFound(extensions.Resource("replicasets/scale"), name)
|
||||
@@ -172,6 +172,7 @@ func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo r
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
// TODO: should this pass admission?
|
||||
obj, err := objInfo.UpdatedObject(ctx, oldScale)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -190,7 +191,7 @@ func (r *ScaleREST) Update(ctx genericapirequest.Context, name string, objInfo r
|
||||
|
||||
rs.Spec.Replicas = scale.Spec.Replicas
|
||||
rs.ResourceVersion = scale.ResourceVersion
|
||||
rs, err = r.registry.UpdateReplicaSet(ctx, rs)
|
||||
rs, err = r.registry.UpdateReplicaSet(ctx, rs, createValidation, updateValidation)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func newStorage(t *testing.T) (*ReplicaSetStorage, *etcdtesting.EtcdTestServer)
|
||||
// createReplicaSet is a helper function that returns a ReplicaSet with the updated resource version.
|
||||
func createReplicaSet(storage *REST, rs extensions.ReplicaSet, t *testing.T) (extensions.ReplicaSet, error) {
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), rs.Namespace)
|
||||
obj, err := storage.Create(ctx, &rs, false)
|
||||
obj, err := storage.Create(ctx, &rs, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create ReplicaSet, %v", err)
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func TestGenerationNumber(t *testing.T) {
|
||||
|
||||
// Updates to spec should increment the generation number
|
||||
storedRS.Spec.Replicas += 1
|
||||
storage.ReplicaSet.Update(ctx, storedRS.Name, rest.DefaultUpdatedObjectInfo(storedRS))
|
||||
storage.ReplicaSet.Update(ctx, storedRS.Name, rest.DefaultUpdatedObjectInfo(storedRS), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func TestGenerationNumber(t *testing.T) {
|
||||
|
||||
// Updates to status should not increment either spec or status generation numbers
|
||||
storedRS.Status.Replicas += 1
|
||||
storage.ReplicaSet.Update(ctx, storedRS.Name, rest.DefaultUpdatedObjectInfo(storedRS))
|
||||
storage.ReplicaSet.Update(ctx, storedRS.Name, rest.DefaultUpdatedObjectInfo(storedRS), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("error updating scale %v: %v", update, err)
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ func TestScaleUpdate(t *testing.T) {
|
||||
update.ResourceVersion = rs.ResourceVersion
|
||||
update.Spec.Replicas = 15
|
||||
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil && !errors.IsConflict(err) {
|
||||
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil && !errors.IsConflict(err) {
|
||||
t.Fatalf("unexpected error, expecting an update conflict but got %v", err)
|
||||
}
|
||||
}
|
||||
@@ -352,7 +352,7 @@ func TestStatusUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := storage.Status.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := storage.Status.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
obj, err := storage.ReplicaSet.Get(ctx, "foo", &metav1.GetOptions{})
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store NetworkPolicies.
|
||||
type Registry interface {
|
||||
ListNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*networking.NetworkPolicyList, error)
|
||||
CreateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy) error
|
||||
UpdateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy) error
|
||||
CreateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetNetworkPolicy(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*networking.NetworkPolicy, error)
|
||||
DeleteNetworkPolicy(ctx genericapirequest.Context, name string) error
|
||||
WatchNetworkPolicies(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,13 @@ func (s *storage) ListNetworkPolicies(ctx genericapirequest.Context, options *me
|
||||
return obj.(*networking.NetworkPolicyList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy) error {
|
||||
_, err := s.Create(ctx, np, false)
|
||||
func (s *storage) CreateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, np, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy) error {
|
||||
_, _, err := s.Update(ctx, np.Name, rest.DefaultUpdatedObjectInfo(np))
|
||||
func (s *storage) UpdateNetworkPolicy(ctx genericapirequest.Context, np *networking.NetworkPolicy, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, np.Name, rest.DefaultUpdatedObjectInfo(np), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,6 @@ func (r *StatusREST) Get(ctx genericapirequest.Context, name string, options *me
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer)
|
||||
// createPodDisruptionBudget is a helper function that returns a PodDisruptionBudget with the updated resource version.
|
||||
func createPodDisruptionBudget(storage *REST, pdb policy.PodDisruptionBudget, t *testing.T) (policy.PodDisruptionBudget, error) {
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), pdb.Namespace)
|
||||
obj, err := storage.Create(ctx, &pdb, false)
|
||||
obj, err := storage.Create(ctx, &pdb, rest.ValidateAllObjectFunc, false)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create PodDisruptionBudget, %v", err)
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func TestStatusUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
if _, _, err := statusStorage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update)); err != nil {
|
||||
if _, _, err := statusStorage.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
obj, err = storage.Get(ctx, "foo", &metav1.GetOptions{})
|
||||
|
||||
@@ -40,9 +40,9 @@ func NewStorage(s rest.StandardStorage, ruleResolver rbacregistryvalidation.Auth
|
||||
return &Storage{s, ruleResolver}
|
||||
}
|
||||
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidatingAdmission rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidatingAdmission, includeUninitialized)
|
||||
}
|
||||
|
||||
clusterRole := obj.(*rbac.ClusterRole)
|
||||
@@ -50,12 +50,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, incl
|
||||
if err := rbacregistryvalidation.ConfirmNoEscalation(ctx, s.ruleResolver, rules); err != nil {
|
||||
return nil, errors.NewForbidden(groupResource, clusterRole.Name, err)
|
||||
}
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidatingAdmission, includeUninitialized)
|
||||
}
|
||||
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Update(ctx, name, obj)
|
||||
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
|
||||
@@ -73,5 +73,5 @@ func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.Up
|
||||
return obj, nil
|
||||
})
|
||||
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store ClusterRoles.
|
||||
type Registry interface {
|
||||
ListClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleList, error)
|
||||
CreateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole) error
|
||||
UpdateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole) error
|
||||
CreateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetClusterRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRole, error)
|
||||
DeleteClusterRole(ctx genericapirequest.Context, name string) error
|
||||
WatchClusterRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,13 @@ func (s *storage) ListClusterRoles(ctx genericapirequest.Context, options *metai
|
||||
return obj.(*rbac.ClusterRoleList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole) error {
|
||||
_, err := s.Create(ctx, clusterRole, false)
|
||||
func (s *storage) CreateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, clusterRole, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole) error {
|
||||
_, _, err := s.Update(ctx, clusterRole.Name, rest.DefaultUpdatedObjectInfo(clusterRole))
|
||||
func (s *storage) UpdateClusterRole(ctx genericapirequest.Context, clusterRole *rbac.ClusterRole, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, clusterRole.Name, rest.DefaultUpdatedObjectInfo(clusterRole), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe
|
||||
return &Storage{s, authorizer, ruleResolver}
|
||||
}
|
||||
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
clusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
|
||||
if rbacregistry.BindingAuthorized(ctx, clusterRoleBinding.RoleRef, metav1.NamespaceNone, s.authorizer) {
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
rules, err := s.ruleResolver.GetRoleReferenceRules(clusterRoleBinding.RoleRef, metav1.NamespaceNone)
|
||||
@@ -61,12 +61,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, incl
|
||||
if err := rbacregistryvalidation.ConfirmNoEscalation(ctx, s.ruleResolver, rules); err != nil {
|
||||
return nil, errors.NewForbidden(groupResource, clusterRoleBinding.Name, err)
|
||||
}
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Update(ctx, name, obj)
|
||||
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
|
||||
@@ -93,5 +93,5 @@ func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.Up
|
||||
return obj, nil
|
||||
})
|
||||
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store ClusterRoleBindings.
|
||||
type Registry interface {
|
||||
ListClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.ClusterRoleBindingList, error)
|
||||
CreateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding) error
|
||||
UpdateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding) error
|
||||
CreateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetClusterRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.ClusterRoleBinding, error)
|
||||
DeleteClusterRoleBinding(ctx genericapirequest.Context, name string) error
|
||||
WatchClusterRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,13 @@ func (s *storage) ListClusterRoleBindings(ctx genericapirequest.Context, options
|
||||
return obj.(*rbac.ClusterRoleBindingList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding) error {
|
||||
_, err := s.Create(ctx, clusterRoleBinding, false)
|
||||
func (s *storage) CreateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, clusterRoleBinding, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding) error {
|
||||
_, _, err := s.Update(ctx, clusterRoleBinding.Name, rest.DefaultUpdatedObjectInfo(clusterRoleBinding))
|
||||
func (s *storage) UpdateClusterRoleBinding(ctx genericapirequest.Context, clusterRoleBinding *rbac.ClusterRoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, clusterRoleBinding.Name, rest.DefaultUpdatedObjectInfo(clusterRoleBinding), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ func NewStorage(s rest.StandardStorage, ruleResolver rbacregistryvalidation.Auth
|
||||
return &Storage{s, ruleResolver}
|
||||
}
|
||||
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
role := obj.(*rbac.Role)
|
||||
@@ -50,12 +50,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, incl
|
||||
if err := rbacregistryvalidation.ConfirmNoEscalation(ctx, s.ruleResolver, rules); err != nil {
|
||||
return nil, errors.NewForbidden(groupResource, role.Name, err)
|
||||
}
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Update(ctx, name, obj)
|
||||
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
|
||||
@@ -73,5 +73,5 @@ func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.Up
|
||||
return obj, nil
|
||||
})
|
||||
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store Roles.
|
||||
type Registry interface {
|
||||
ListRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleList, error)
|
||||
CreateRole(ctx genericapirequest.Context, role *rbac.Role) error
|
||||
UpdateRole(ctx genericapirequest.Context, role *rbac.Role) error
|
||||
CreateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetRole(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.Role, error)
|
||||
DeleteRole(ctx genericapirequest.Context, name string) error
|
||||
WatchRoles(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,14 @@ func (s *storage) ListRoles(ctx genericapirequest.Context, options *metainternal
|
||||
return obj.(*rbac.RoleList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateRole(ctx genericapirequest.Context, role *rbac.Role) error {
|
||||
_, err := s.Create(ctx, role, false)
|
||||
func (s *storage) CreateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, role, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateRole(ctx genericapirequest.Context, role *rbac.Role) error {
|
||||
_, _, err := s.Update(ctx, role.Name, rest.DefaultUpdatedObjectInfo(role))
|
||||
func (s *storage) UpdateRole(ctx genericapirequest.Context, role *rbac.Role, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
// TODO: any admission?
|
||||
_, _, err := s.Update(ctx, role.Name, rest.DefaultUpdatedObjectInfo(role), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe
|
||||
return &Storage{s, authorizer, ruleResolver}
|
||||
}
|
||||
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, includeUninitialized bool) (runtime.Object, error) {
|
||||
func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, includeUninitialized bool) (runtime.Object, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
// Get the namespace from the context (populated from the URL).
|
||||
@@ -57,7 +57,7 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, incl
|
||||
|
||||
roleBinding := obj.(*rbac.RoleBinding)
|
||||
if rbacregistry.BindingAuthorized(ctx, roleBinding.RoleRef, namespace, s.authorizer) {
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
rules, err := s.ruleResolver.GetRoleReferenceRules(roleBinding.RoleRef, namespace)
|
||||
@@ -67,12 +67,12 @@ func (s *Storage) Create(ctx genericapirequest.Context, obj runtime.Object, incl
|
||||
if err := rbacregistryvalidation.ConfirmNoEscalation(ctx, s.ruleResolver, rules); err != nil {
|
||||
return nil, errors.NewForbidden(groupResource, roleBinding.Name, err)
|
||||
}
|
||||
return s.StandardStorage.Create(ctx, obj, includeUninitialized)
|
||||
return s.StandardStorage.Create(ctx, obj, createValidation, includeUninitialized)
|
||||
}
|
||||
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
if rbacregistry.EscalationAllowed(ctx) {
|
||||
return s.StandardStorage.Update(ctx, name, obj)
|
||||
return s.StandardStorage.Update(ctx, name, obj, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx genericapirequest.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
|
||||
@@ -106,5 +106,5 @@ func (s *Storage) Update(ctx genericapirequest.Context, name string, obj rest.Up
|
||||
return obj, nil
|
||||
})
|
||||
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
|
||||
return s.StandardStorage.Update(ctx, name, nonEscalatingInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store RoleBindings.
|
||||
type Registry interface {
|
||||
ListRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*rbac.RoleBindingList, error)
|
||||
CreateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding) error
|
||||
UpdateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding) error
|
||||
CreateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error
|
||||
UpdateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetRoleBinding(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*rbac.RoleBinding, error)
|
||||
DeleteRoleBinding(ctx genericapirequest.Context, name string) error
|
||||
WatchRoleBindings(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,14 +55,14 @@ func (s *storage) ListRoleBindings(ctx genericapirequest.Context, options *metai
|
||||
return obj.(*rbac.RoleBindingList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding) error {
|
||||
func (s *storage) CreateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc) error {
|
||||
// TODO(ericchiang): add additional validation
|
||||
_, err := s.Create(ctx, roleBinding, false)
|
||||
_, err := s.Create(ctx, roleBinding, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding) error {
|
||||
_, _, err := s.Update(ctx, roleBinding.Name, rest.DefaultUpdatedObjectInfo(roleBinding))
|
||||
func (s *storage) UpdateRoleBinding(ctx genericapirequest.Context, roleBinding *rbac.RoleBinding, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, roleBinding.Name, rest.DefaultUpdatedObjectInfo(roleBinding), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
)
|
||||
|
||||
@@ -66,7 +67,7 @@ func (e *EndpointRegistry) WatchEndpoints(ctx genericapirequest.Context, options
|
||||
return nil, fmt.Errorf("unimplemented!")
|
||||
}
|
||||
|
||||
func (e *EndpointRegistry) UpdateEndpoints(ctx genericapirequest.Context, endpoints *api.Endpoints) error {
|
||||
func (e *EndpointRegistry) UpdateEndpoints(ctx genericapirequest.Context, endpoints *api.Endpoints, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
// TODO: support namespaces in this mock
|
||||
e.lock.Lock()
|
||||
defer e.lock.Unlock()
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
)
|
||||
|
||||
@@ -72,7 +73,7 @@ func (r *ServiceRegistry) ListServices(ctx genericapirequest.Context, options *m
|
||||
return res, r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) CreateService(ctx genericapirequest.Context, svc *api.Service) (*api.Service, error) {
|
||||
func (r *ServiceRegistry) CreateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc) (*api.Service, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
@@ -99,7 +100,7 @@ func (r *ServiceRegistry) DeleteService(ctx genericapirequest.Context, id string
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func (r *ServiceRegistry) UpdateService(ctx genericapirequest.Context, svc *api.Service) (*api.Service, error) {
|
||||
func (r *ServiceRegistry) UpdateService(ctx genericapirequest.Context, svc *api.Service, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (*api.Service, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store PriorityClass.
|
||||
type Registry interface {
|
||||
ListPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*scheduling.PriorityClassList, error)
|
||||
CreatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass) error
|
||||
UpdatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass) error
|
||||
CreatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error
|
||||
UpdatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetPriorityClass(ctx genericapirequest.Context, name string, options *metav1.GetOptions) (*scheduling.PriorityClass, error)
|
||||
DeletePriorityClass(ctx genericapirequest.Context, name string) error
|
||||
WatchPriorityClasses(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,13 @@ func (s *storage) ListPriorityClasses(ctx genericapirequest.Context, options *me
|
||||
return obj.(*scheduling.PriorityClassList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass) error {
|
||||
_, err := s.Create(ctx, pc, false)
|
||||
func (s *storage) CreatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, pc, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass) error {
|
||||
_, _, err := s.Update(ctx, pc.Name, rest.DefaultUpdatedObjectInfo(pc))
|
||||
func (s *storage) UpdatePriorityClass(ctx genericapirequest.Context, pc *scheduling.PriorityClass, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, pc.Name, rest.DefaultUpdatedObjectInfo(pc), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
// Registry is an interface for things that know how to store PodPresets.
|
||||
type Registry interface {
|
||||
ListPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (*settings.PodPresetList, error)
|
||||
CreatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset) error
|
||||
UpdatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset) error
|
||||
CreatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error
|
||||
UpdatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error
|
||||
GetPodPreset(ctx genericapirequest.Context, ppID string, options *metav1.GetOptions) (*settings.PodPreset, error)
|
||||
DeletePodPreset(ctx genericapirequest.Context, ppID string) error
|
||||
WatchPodPresets(ctx genericapirequest.Context, options *metainternalversion.ListOptions) (watch.Interface, error)
|
||||
@@ -55,13 +55,13 @@ func (s *storage) ListPodPresets(ctx genericapirequest.Context, options *metaint
|
||||
return obj.(*settings.PodPresetList), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset) error {
|
||||
_, err := s.Create(ctx, pp, false)
|
||||
func (s *storage) CreatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc) error {
|
||||
_, err := s.Create(ctx, pp, createValidation, false)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *storage) UpdatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset) error {
|
||||
_, _, err := s.Update(ctx, pp.Name, rest.DefaultUpdatedObjectInfo(pp))
|
||||
func (s *storage) UpdatePodPreset(ctx genericapirequest.Context, pp *settings.PodPreset, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) error {
|
||||
_, _, err := s.Update(ctx, pp.Name, rest.DefaultUpdatedObjectInfo(pp), createValidation, updateValidation)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ func (AlwaysAdmit) Admit(a admission.Attributes) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate makes an admission decision based on the request attributes. It is NOT allowed to mutate.
|
||||
func (AlwaysAdmit) Validate(a admission.Attributes) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Handles returns true if this admission controller can handle the given operation
|
||||
// where operation can be one of CREATE, UPDATE, DELETE, or CONNECT
|
||||
func (AlwaysAdmit) Handles(operation admission.Operation) bool {
|
||||
|
||||
@@ -135,8 +135,8 @@ func (d *DenyExec) SetInternalKubeClientSet(client internalclientset.Interface)
|
||||
d.client = client
|
||||
}
|
||||
|
||||
// Validate implements the Validator interface.
|
||||
func (d *DenyExec) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (d *DenyExec) ValidateInitialization() error {
|
||||
if d.client == nil {
|
||||
return fmt.Errorf("missing client")
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ func testAdmission(t *testing.T, pod *api.Pod, handler *DenyExec, shouldAccept b
|
||||
})
|
||||
|
||||
handler.SetInternalKubeClientSet(mockClient)
|
||||
admission.Validate(handler)
|
||||
admission.ValidateInitialization(handler)
|
||||
|
||||
// pods/exec
|
||||
{
|
||||
|
||||
@@ -260,7 +260,7 @@ func (a *gcPermissionsEnforcement) SetRESTMapper(restMapper meta.RESTMapper) {
|
||||
a.restMapper = restMapper
|
||||
}
|
||||
|
||||
func (a *gcPermissionsEnforcement) Validate() error {
|
||||
func (a *gcPermissionsEnforcement) ValidateInitialization() error {
|
||||
if a.authorizer == nil {
|
||||
return fmt.Errorf("missing authorizer")
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func expectNoAnnotation(t *testing.T, pod *api.Pod) {
|
||||
}
|
||||
}
|
||||
|
||||
func admit(t *testing.T, ir admission.Interface, pods []*api.Pod) {
|
||||
func admit(t *testing.T, ir admission.MutationInterface, pods []*api.Pod) {
|
||||
for i := range pods {
|
||||
p := pods[i]
|
||||
|
||||
@@ -123,7 +123,7 @@ func admit(t *testing.T, ir admission.Interface, pods []*api.Pod) {
|
||||
}
|
||||
}
|
||||
|
||||
func testAdminScenarios(t *testing.T, ir admission.Interface, p *api.Pod) {
|
||||
func testAdminScenarios(t *testing.T, ir admission.MutationInterface, p *api.Pod) {
|
||||
podKind := api.Kind("Pod").WithVersion("version")
|
||||
podRes := api.Resource("pods").WithVersion("version")
|
||||
|
||||
@@ -151,7 +151,7 @@ func testAdminScenarios(t *testing.T, ir admission.Interface, p *api.Pod) {
|
||||
}
|
||||
}
|
||||
|
||||
func performTest(t *testing.T, ir admission.Interface) {
|
||||
func performTest(t *testing.T, ir admission.MutationInterface) {
|
||||
pods := getPods()
|
||||
admit(t, ir, pods)
|
||||
testAdminScenarios(t, ir, pods[0])
|
||||
|
||||
@@ -75,7 +75,7 @@ func (l *LimitRanger) SetInternalKubeInformerFactory(f informers.SharedInformerF
|
||||
l.lister = limitRangeInformer.Lister()
|
||||
}
|
||||
|
||||
func (l *LimitRanger) Validate() error {
|
||||
func (l *LimitRanger) ValidateInitialization() error {
|
||||
if l.lister == nil {
|
||||
return fmt.Errorf("missing limitRange lister")
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ func newHandlerForTest(c clientset.Interface) (*LimitRanger, informers.SharedInf
|
||||
}
|
||||
pluginInitializer := kubeadmission.NewPluginInitializer(c, f, nil, nil, nil, nil, nil)
|
||||
pluginInitializer.Initialize(handler)
|
||||
err = admission.Validate(handler)
|
||||
err = admission.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ func (p *Provision) SetInternalKubeInformerFactory(f informers.SharedInformerFac
|
||||
p.SetReadyFunc(namespaceInformer.Informer().HasSynced)
|
||||
}
|
||||
|
||||
// Validate implements the Validator interface.
|
||||
func (p *Provision) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (p *Provision) ValidateInitialization() error {
|
||||
if p.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
||||
@@ -35,12 +35,12 @@ import (
|
||||
)
|
||||
|
||||
// newHandlerForTest returns the admission controller configured for testing.
|
||||
func newHandlerForTest(c clientset.Interface) (admission.Interface, informers.SharedInformerFactory, error) {
|
||||
func newHandlerForTest(c clientset.Interface) (admission.MutationInterface, informers.SharedInformerFactory, error) {
|
||||
f := informers.NewSharedInformerFactory(c, 5*time.Minute)
|
||||
handler := NewProvision()
|
||||
pluginInitializer := kubeadmission.NewPluginInitializer(c, f, nil, nil, nil, nil, nil)
|
||||
pluginInitializer.Initialize(handler)
|
||||
err := admission.Validate(handler)
|
||||
err := admission.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@ func (e *Exists) SetInternalKubeInformerFactory(f informers.SharedInformerFactor
|
||||
e.SetReadyFunc(namespaceInformer.Informer().HasSynced)
|
||||
}
|
||||
|
||||
// Validate implements the Validator interface.
|
||||
func (e *Exists) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (e *Exists) ValidateInitialization() error {
|
||||
if e.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ import (
|
||||
)
|
||||
|
||||
// newHandlerForTest returns the admission controller configured for testing.
|
||||
func newHandlerForTest(c clientset.Interface) (admission.Interface, informers.SharedInformerFactory, error) {
|
||||
func newHandlerForTest(c clientset.Interface) (admission.MutationInterface, informers.SharedInformerFactory, error) {
|
||||
f := informers.NewSharedInformerFactory(c, 5*time.Minute)
|
||||
handler := NewExists()
|
||||
pluginInitializer := kubeadmission.NewPluginInitializer(c, f, nil, nil, nil, nil, nil)
|
||||
pluginInitializer.Initialize(handler)
|
||||
err := admission.Validate(handler)
|
||||
err := admission.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func (p *nodePlugin) SetInternalKubeClientSet(f internalclientset.Interface) {
|
||||
p.podsGetter = f.Core()
|
||||
}
|
||||
|
||||
func (p *nodePlugin) Validate() error {
|
||||
func (p *nodePlugin) ValidateInitialization() error {
|
||||
if p.nodeIdentifier == nil {
|
||||
return fmt.Errorf("%s requires a node identifier", PluginName)
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ func (pvcr *persistentVolumeClaimResize) SetInternalKubeInformerFactory(f inform
|
||||
})
|
||||
}
|
||||
|
||||
// Validate ensures lister is set.
|
||||
func (pvcr *persistentVolumeClaimResize) Validate() error {
|
||||
// ValidateInitialization ensures lister is set.
|
||||
func (pvcr *persistentVolumeClaimResize) ValidateInitialization() error {
|
||||
if pvcr.pvLister == nil {
|
||||
return fmt.Errorf("missing persistent volume lister")
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ func TestPVCResizeAdmission(t *testing.T) {
|
||||
ctrl := newPlugin()
|
||||
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
|
||||
ctrl.SetInternalKubeInformerFactory(informerFactory)
|
||||
err := ctrl.Validate()
|
||||
err := ctrl.ValidateInitialization()
|
||||
if err != nil {
|
||||
t.Fatalf("neither pv lister nor storageclass lister can be nil")
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ func (p *podNodeSelector) SetInternalKubeInformerFactory(f informers.SharedInfor
|
||||
p.SetReadyFunc(namespaceInformer.Informer().HasSynced)
|
||||
}
|
||||
|
||||
func (p *podNodeSelector) Validate() error {
|
||||
func (p *podNodeSelector) ValidateInitialization() error {
|
||||
if p.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
||||
@@ -243,6 +243,6 @@ func newHandlerForTest(c clientset.Interface) (*podNodeSelector, informers.Share
|
||||
handler := NewPodNodeSelector(nil)
|
||||
pluginInitializer := kubeadmission.NewPluginInitializer(c, f, nil, nil, nil, nil, nil)
|
||||
pluginInitializer.Initialize(handler)
|
||||
err := admission.Validate(handler)
|
||||
err := admission.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func NewPlugin() *podPresetPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
func (plugin *podPresetPlugin) Validate() error {
|
||||
func (plugin *podPresetPlugin) ValidateInitialization() error {
|
||||
if plugin.client == nil {
|
||||
return fmt.Errorf("%s requires a client", pluginName)
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ func TestMergeVolumes(t *testing.T) {
|
||||
|
||||
// NewTestAdmission provides an admission plugin with test implementations of internal structs. It uses
|
||||
// an authorizer that always returns true.
|
||||
func NewTestAdmission(lister settingslisters.PodPresetLister, objects ...runtime.Object) kadmission.Interface {
|
||||
func NewTestAdmission(lister settingslisters.PodPresetLister, objects ...runtime.Object) kadmission.MutationInterface {
|
||||
// Build a test client that the admission plugin can use to look up the service account missing from its cache
|
||||
client := fake.NewSimpleClientset(objects...)
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ func (p *podTolerationsPlugin) SetInternalKubeInformerFactory(f informers.Shared
|
||||
|
||||
}
|
||||
|
||||
func (p *podTolerationsPlugin) Validate() error {
|
||||
func (p *podTolerationsPlugin) ValidateInitialization() error {
|
||||
if p.namespaceLister == nil {
|
||||
return fmt.Errorf("missing namespaceLister")
|
||||
}
|
||||
|
||||
@@ -363,6 +363,6 @@ func newHandlerForTest(c clientset.Interface) (*podTolerationsPlugin, informers.
|
||||
handler := NewPodTolerationsPlugin(pluginConfig)
|
||||
pluginInitializer := kubeadmission.NewPluginInitializer(c, f, nil, nil, nil, nil, nil)
|
||||
pluginInitializer.Initialize(handler)
|
||||
err = admission.Validate(handler)
|
||||
err = admission.ValidateInitialization(handler)
|
||||
return handler, f, err
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ func NewPlugin() *PriorityPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Validate implements the Validator interface.
|
||||
func (p *PriorityPlugin) Validate() error {
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (p *PriorityPlugin) ValidateInitialization() error {
|
||||
if p.client == nil {
|
||||
return fmt.Errorf("%s requires a client", pluginName)
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ func (a *QuotaAdmission) SetQuotaConfiguration(c quota.Configuration) {
|
||||
a.evaluator = NewQuotaEvaluator(a.quotaAccessor, a.quotaConfiguration, nil, a.config, a.numEvaluators, a.stopCh)
|
||||
}
|
||||
|
||||
// Validate ensures an authorizer is set.
|
||||
func (a *QuotaAdmission) Validate() error {
|
||||
// ValidateInitialization ensures an authorizer is set.
|
||||
func (a *QuotaAdmission) ValidateInitialization() error {
|
||||
if a.quotaAccessor == nil {
|
||||
return fmt.Errorf("missing quotaAccessor")
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ func (plugin *podSecurityPolicyPlugin) SetAuthorizer(authz authorizer.Authorizer
|
||||
plugin.authz = authz
|
||||
}
|
||||
|
||||
// Validate ensures an authorizer is set.
|
||||
func (plugin *podSecurityPolicyPlugin) Validate() error {
|
||||
// ValidateInitialization ensures an authorizer is set.
|
||||
func (plugin *podSecurityPolicyPlugin) ValidateInitialization() error {
|
||||
if plugin.authz == nil {
|
||||
return fmt.Errorf("%s requires an authorizer", PluginName)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ const defaultContainerName = "test-c"
|
||||
|
||||
// NewTestAdmission provides an admission plugin with test implementations of internal structs. It uses
|
||||
// an authorizer that always returns true.
|
||||
func NewTestAdmission(lister extensionslisters.PodSecurityPolicyLister) kadmission.Interface {
|
||||
func NewTestAdmission(lister extensionslisters.PodSecurityPolicyLister) kadmission.MutationInterface {
|
||||
return &podSecurityPolicyPlugin{
|
||||
Handler: kadmission.NewHandler(kadmission.Create, kadmission.Update),
|
||||
strategyFactory: kpsp.NewSimpleStrategyFactory(),
|
||||
|
||||
@@ -117,8 +117,8 @@ func (a *serviceAccount) SetInternalKubeInformerFactory(f informers.SharedInform
|
||||
})
|
||||
}
|
||||
|
||||
// Validate ensures an authorizer is set.
|
||||
func (a *serviceAccount) Validate() error {
|
||||
// ValidateInitialization ensures an authorizer is set.
|
||||
func (a *serviceAccount) ValidateInitialization() error {
|
||||
if a.client == nil {
|
||||
return fmt.Errorf("missing client")
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ func (a *claimDefaulterPlugin) SetInternalKubeInformerFactory(f informers.Shared
|
||||
a.SetReadyFunc(informer.Informer().HasSynced)
|
||||
}
|
||||
|
||||
// Validate ensures lister is set.
|
||||
func (a *claimDefaulterPlugin) Validate() error {
|
||||
// ValidateInitialization ensures lister is set.
|
||||
func (a *claimDefaulterPlugin) ValidateInitialization() error {
|
||||
if a.lister == nil {
|
||||
return fmt.Errorf("missing lister")
|
||||
}
|
||||
|
||||
@@ -167,6 +167,6 @@ func (r *StatusREST) New() runtime.Object {
|
||||
}
|
||||
|
||||
// Update alters the status subset of an object.
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo)
|
||||
func (r *StatusREST) Update(ctx genericapirequest.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc) (runtime.Object, bool, error) {
|
||||
return r.store.Update(ctx, name, objInfo, createValidation, updateValidation)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user