// Update replaces a given Route instance with an existing instance in rs.registry. func (rs *REST) Update(ctx kapi.Context, obj runtime.Object) (runtime.Object, bool, error) { route, ok := obj.(*api.Route) if !ok { return nil, false, errors.NewBadRequest(fmt.Sprintf("not a route: %#v", obj)) } if !kapi.ValidNamespace(ctx, &route.ObjectMeta) { return nil, false, errors.NewConflict("route", route.Namespace, fmt.Errorf("Route.Namespace does not match the provided context")) } old, err := rs.Get(ctx, route.Name) if err != nil { return nil, false, err } if errs := validation.ValidateRouteUpdate(route, old.(*api.Route)); len(errs) > 0 { return nil, false, errors.NewInvalid("route", route.Name, errs) } // TODO: Convert to generic etcd // TODO: Call ValidateRouteUpdate->ValidateObjectMetaUpdate // TODO: In the UpdateStrategy.PrepareForUpdate, set the HostGeneratedAnnotationKey annotation to "false" if the updated route object modifies the host err = rs.registry.UpdateRoute(ctx, route) if err != nil { return nil, false, err } out, err := rs.registry.GetRoute(ctx, route.Name) return out, false, err }
func (routeStrategy) ValidateUpdate(ctx kapi.Context, obj, old runtime.Object) field.ErrorList { oldRoute := old.(*api.Route) objRoute := obj.(*api.Route) return validation.ValidateRouteUpdate(objRoute, oldRoute) }