From 69d1d235cdb2e05538894da875c898b6bc5ccb84 Mon Sep 17 00:00:00 2001 From: markturansky Date: Tue, 31 Mar 2015 12:32:26 -0400 Subject: [PATCH] Rebased and updated --- pkg/registry/persistentvolume/etcd/etcd.go | 2 +- pkg/registry/persistentvolume/rest.go | 16 ++-------------- pkg/registry/persistentvolumeclaim/etcd/etcd.go | 2 +- pkg/registry/persistentvolumeclaim/rest.go | 9 ++------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/pkg/registry/persistentvolume/etcd/etcd.go b/pkg/registry/persistentvolume/etcd/etcd.go index 69baf3b34db..fa9ce0e0c12 100644 --- a/pkg/registry/persistentvolume/etcd/etcd.go +++ b/pkg/registry/persistentvolume/etcd/etcd.go @@ -56,7 +56,7 @@ func NewStorage(h tools.EtcdHelper) (*REST, *StatusREST) { } store.CreateStrategy = persistentvolume.Strategy - store.UpdateStrategy = persistentvolume.Strategy + store.UpdateStrategy = persistentvolume.StatusStrategy store.ReturnDeletedObject = true statusStore := *store diff --git a/pkg/registry/persistentvolume/rest.go b/pkg/registry/persistentvolume/rest.go index 8de5c44f4b4..b15e58f07d4 100644 --- a/pkg/registry/persistentvolume/rest.go +++ b/pkg/registry/persistentvolume/rest.go @@ -49,15 +49,8 @@ func (persistentvolumeStrategy) PrepareForCreate(obj runtime.Object) { pv.Status = api.PersistentVolumeStatus{} } -// PrepareForUpdate clears fields that are not allowed to be set by end users on update. -func (persistentvolumeStrategy) PrepareForUpdate(obj, old runtime.Object) { - newPv := obj.(*api.PersistentVolume) - oldPv := obj.(*api.PersistentVolume) - newPv.Status = oldPv.Status -} - // Validate validates a new persistentvolume. -func (persistentvolumeStrategy) Validate(obj runtime.Object) fielderrors.ValidationErrorList { +func (persistentvolumeStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList { persistentvolume := obj.(*api.PersistentVolume) return validation.ValidatePersistentVolume(persistentvolume) } @@ -67,11 +60,6 @@ func (persistentvolumeStrategy) AllowCreateOnUpdate() bool { return false } -// ValidateUpdate is the default update validation for an end user. -func (persistentvolumeStrategy) ValidateUpdate(obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidatePersistentVolumeUpdate(obj.(*api.PersistentVolume), old.(*api.PersistentVolume)) -} - type persistentvolumeStatusStrategy struct { persistentvolumeStrategy } @@ -84,7 +72,7 @@ func (persistentvolumeStatusStrategy) PrepareForUpdate(obj, old runtime.Object) newPv.Spec = oldPv.Spec } -func (persistentvolumeStatusStrategy) ValidateUpdate(obj, old runtime.Object) fielderrors.ValidationErrorList { +func (persistentvolumeStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { return validation.ValidatePersistentVolumeStatusUpdate(obj.(*api.PersistentVolume), old.(*api.PersistentVolume)) } diff --git a/pkg/registry/persistentvolumeclaim/etcd/etcd.go b/pkg/registry/persistentvolumeclaim/etcd/etcd.go index ada9ce88d89..9b57cabf176 100644 --- a/pkg/registry/persistentvolumeclaim/etcd/etcd.go +++ b/pkg/registry/persistentvolumeclaim/etcd/etcd.go @@ -56,7 +56,7 @@ func NewStorage(h tools.EtcdHelper) *REST { } store.CreateStrategy = persistentvolumeclaim.Strategy - store.UpdateStrategy = persistentvolumeclaim.Strategy + store.UpdateStrategy = persistentvolumeclaim.StatusStrategy store.ReturnDeletedObject = true return &REST{store} diff --git a/pkg/registry/persistentvolumeclaim/rest.go b/pkg/registry/persistentvolumeclaim/rest.go index 82d2f1300a6..fafe02b365f 100644 --- a/pkg/registry/persistentvolumeclaim/rest.go +++ b/pkg/registry/persistentvolumeclaim/rest.go @@ -57,7 +57,7 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(obj, old runtime.Object) { } // Validate validates a new persistentvolumeclaim. -func (persistentvolumeclaimStrategy) Validate(obj runtime.Object) fielderrors.ValidationErrorList { +func (persistentvolumeclaimStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.ValidationErrorList { pvc := obj.(*api.PersistentVolumeClaim) return validation.ValidatePersistentVolumeClaim(pvc) } @@ -67,11 +67,6 @@ func (persistentvolumeclaimStrategy) AllowCreateOnUpdate() bool { return false } -// ValidateUpdate is the default update validation for an end user. -func (persistentvolumeclaimStrategy) ValidateUpdate(obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidatePersistentVolumeClaimUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim)) -} - type persistentvolumeclaimStatusStrategy struct { persistentvolumeclaimStrategy } @@ -84,7 +79,7 @@ func (persistentvolumeclaimStatusStrategy) PrepareForUpdate(obj, old runtime.Obj newPvc.Spec = oldPvc.Spec } -func (persistentvolumeclaimStatusStrategy) ValidateUpdate(obj, old runtime.Object) fielderrors.ValidationErrorList { +func (persistentvolumeclaimStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { return validation.ValidatePersistentVolumeClaimStatusUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim)) }