// Update replaces a given ReplicationController instance with an existing instance in storage.registry. func (storage *ControllerRegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { controller, ok := obj.(*api.ReplicationController) if !ok { return nil, fmt.Errorf("not a replication controller: %#v", obj) } if errs := api.ValidateReplicationController(controller); len(errs) > 0 { return nil, fmt.Errorf("Validation errors: %v", errs) } return apiserver.MakeAsync(func() (interface{}, error) { err := storage.registry.UpdateController(*controller) if err != nil { return nil, err } return storage.waitForController(*controller) }), nil }
// Update replaces a given ReplicationController instance with an existing // instance in storage.registry. func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) { controller, ok := obj.(*api.ReplicationController) if !ok { return nil, fmt.Errorf("not a replication controller: %#v", obj) } if errs := api.ValidateReplicationController(controller); len(errs) > 0 { return nil, apiserver.NewInvalidErr("replicationController", controller.ID, errs) } return apiserver.MakeAsync(func() (interface{}, error) { err := rs.registry.UpdateController(*controller) if err != nil { return nil, err } return rs.registry.GetController(controller.ID) }), nil }
// Create registers then given ReplicationController. func (rs *RegistryStorage) Create(obj interface{}) (<-chan interface{}, error) { controller, ok := obj.(*api.ReplicationController) if !ok { return nil, fmt.Errorf("not a replication controller: %#v", obj) } if len(controller.ID) == 0 { controller.ID = uuid.NewUUID().String() } // Pod Manifest ID should be assigned by the pod API controller.DesiredState.PodTemplate.DesiredState.Manifest.ID = "" if errs := api.ValidateReplicationController(controller); len(errs) > 0 { return nil, fmt.Errorf("Validation errors: %v", errs) } return apiserver.MakeAsync(func() (interface{}, error) { err := rs.registry.CreateController(*controller) if err != nil { return nil, err } return rs.waitForController(*controller) }), nil }