mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Rebased and updated
This commit is contained in:
@@ -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
|
||||
|
@@ -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))
|
||||
}
|
||||
|
||||
|
@@ -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}
|
||||
|
@@ -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))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user