// 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) } // RollbackREST implements the REST endpoint for initiating the rollback of a deployment type RollbackREST struct { store *genericregistry.Store } // New creates a rollback func (r *RollbackREST) New() runtime.Object { return &extensions.DeploymentRollback{} } var _ = rest.Creater(&RollbackREST{}) func (r *RollbackREST) Create(ctx genericapirequest.Context, obj runtime.Object) (runtime.Object, error) { rollback, ok := obj.(*extensions.DeploymentRollback) if !ok { return nil, errors.NewBadRequest(fmt.Sprintf("not a DeploymentRollback: %#v", obj)) } if errs := extvalidation.ValidateDeploymentRollback(rollback); len(errs) != 0 { return nil, errors.NewInvalid(extensions.Kind("DeploymentRollback"), rollback.Name, errs) } // Update the Deployment with information in DeploymentRollback to trigger rollback err := r.rollbackDeployment(ctx, rollback.Name, &rollback.RollbackTo, rollback.UpdatedAnnotations) if err != nil { return nil, err
// ResourceLocation returns a pods location from its HostIP func (r *REST) ResourceLocation(ctx genericapirequest.Context, name string) (*url.URL, http.RoundTripper, error) { return pod.ResourceLocation(r, r.proxyTransport, ctx, name) } // BindingREST implements the REST endpoint for binding pods to nodes when etcd is in use. type BindingREST struct { store *genericregistry.Store } // New creates a new binding resource func (r *BindingREST) New() runtime.Object { return &api.Binding{} } var _ = rest.Creater(&BindingREST{}) // Create ensures a pod is bound to a specific host. func (r *BindingREST) Create(ctx genericapirequest.Context, obj runtime.Object) (out runtime.Object, err error) { binding := obj.(*api.Binding) // TODO: move me to a binding strategy if errs := validation.ValidatePodBinding(binding); len(errs) != 0 { return nil, errs.ToAggregate() } err = r.assignPod(ctx, binding.Name, binding.Target.Name, binding.Annotations) out = &metav1.Status{Status: metav1.StatusSuccess} return }
Duration: 500 * time.Millisecond, Factor: 1.0, Jitter: 0.1, } func newEvictionStorage(store *genericregistry.Store, podDisruptionBudgetClient policyclient.PodDisruptionBudgetsGetter) *EvictionREST { return &EvictionREST{store: store, podDisruptionBudgetClient: podDisruptionBudgetClient} } // EvictionREST implements the REST endpoint for evicting pods from nodes type EvictionREST struct { store *genericregistry.Store podDisruptionBudgetClient policyclient.PodDisruptionBudgetsGetter } var _ = rest.Creater(&EvictionREST{}) // New creates a new eviction resource func (r *EvictionREST) New() runtime.Object { return &policy.Eviction{} } // 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) (runtime.Object, error) { eviction := obj.(*policy.Eviction) obj, err := r.store.Get(ctx, eviction.Name, &metav1.GetOptions{}) if err != nil { return nil, err } pod := obj.(*api.Pod)