Change rest storage Update interface to retrieve updated object

Add OldObject to admission attributes

Update resthandler Patch/Update admission plumbing
This commit is contained in:
Jordan Liggitt
2016-04-28 21:21:35 -04:00
parent 4215fe57a5
commit 29252acd1a
71 changed files with 772 additions and 325 deletions

View File

@@ -212,17 +212,22 @@ func (*REST) NewList() runtime.Object {
return &api.ServiceList{}
}
func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, bool, error) {
func (rs *REST) Update(ctx api.Context, name string, objInfo rest.UpdatedObjectInfo) (runtime.Object, bool, error) {
oldService, err := rs.registry.GetService(ctx, name)
if err != nil {
return nil, false, err
}
obj, err := objInfo.UpdatedObject(ctx, oldService)
if err != nil {
return nil, false, err
}
service := obj.(*api.Service)
if !api.ValidNamespace(ctx, &service.ObjectMeta) {
return nil, false, errors.NewConflict(api.Resource("services"), service.Namespace, fmt.Errorf("Service.Namespace does not match the provided context"))
}
oldService, err := rs.registry.GetService(ctx, service.Name)
if err != nil {
return nil, false, err
}
// Copy over non-user fields
// TODO: make this a merge function
if errs := validation.ValidateServiceUpdate(service, oldService); len(errs) > 0 {