mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 22:53:22 +00:00
plumb through changes on ReplicationController and Service
This commit is contained in:
@@ -152,23 +152,25 @@ func (r *Registry) GetController(ctx api.Context, controllerID string) (*api.Rep
|
||||
}
|
||||
|
||||
// CreateController creates a new ReplicationController.
|
||||
func (r *Registry) CreateController(ctx api.Context, controller *api.ReplicationController) error {
|
||||
func (r *Registry) CreateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error) {
|
||||
key, err := makeControllerKey(ctx, controller.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
err = r.CreateObj(key, controller, nil, 0)
|
||||
return etcderr.InterpretCreateError(err, "replicationController", controller.Name)
|
||||
out := &api.ReplicationController{}
|
||||
err = r.CreateObj(key, controller, out, 0)
|
||||
return out, etcderr.InterpretCreateError(err, "replicationController", controller.Name)
|
||||
}
|
||||
|
||||
// UpdateController replaces an existing ReplicationController.
|
||||
func (r *Registry) UpdateController(ctx api.Context, controller *api.ReplicationController) error {
|
||||
func (r *Registry) UpdateController(ctx api.Context, controller *api.ReplicationController) (*api.ReplicationController, error) {
|
||||
key, err := makeControllerKey(ctx, controller.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
err = r.SetObj(key, controller, nil, 0)
|
||||
return etcderr.InterpretUpdateError(err, "replicationController", controller.Name)
|
||||
out := &api.ReplicationController{}
|
||||
err = r.SetObj(key, controller, out, 0)
|
||||
return out, etcderr.InterpretUpdateError(err, "replicationController", controller.Name)
|
||||
}
|
||||
|
||||
// DeleteController deletes a ReplicationController specified by its ID.
|
||||
@@ -199,13 +201,14 @@ func (r *Registry) ListServices(ctx api.Context) (*api.ServiceList, error) {
|
||||
}
|
||||
|
||||
// CreateService creates a new Service.
|
||||
func (r *Registry) CreateService(ctx api.Context, svc *api.Service) error {
|
||||
func (r *Registry) CreateService(ctx api.Context, svc *api.Service) (*api.Service, error) {
|
||||
key, err := makeServiceKey(ctx, svc.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
err = r.CreateObj(key, svc, nil, 0)
|
||||
return etcderr.InterpretCreateError(err, "service", svc.Name)
|
||||
out := &api.Service{}
|
||||
err = r.CreateObj(key, svc, out, 0)
|
||||
return out, etcderr.InterpretCreateError(err, "service", svc.Name)
|
||||
}
|
||||
|
||||
// GetService obtains a Service specified by its name.
|
||||
@@ -270,13 +273,14 @@ func (r *Registry) DeleteService(ctx api.Context, name string) error {
|
||||
}
|
||||
|
||||
// UpdateService replaces an existing Service.
|
||||
func (r *Registry) UpdateService(ctx api.Context, svc *api.Service) error {
|
||||
func (r *Registry) UpdateService(ctx api.Context, svc *api.Service) (*api.Service, error) {
|
||||
key, err := makeServiceKey(ctx, svc.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
err = r.SetObj(key, svc, nil, 0)
|
||||
return etcderr.InterpretUpdateError(err, "service", svc.Name)
|
||||
out := &api.Service{}
|
||||
err = r.SetObj(key, svc, out, 0)
|
||||
return out, etcderr.InterpretUpdateError(err, "service", svc.Name)
|
||||
}
|
||||
|
||||
// WatchServices begins watching for new, changed, or deleted service configurations.
|
||||
|
@@ -212,7 +212,7 @@ func TestEtcdCreateController(t *testing.T) {
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
_, err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
@@ -242,7 +242,7 @@ func TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
_, err := registry.CreateController(ctx, &api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
@@ -259,7 +259,7 @@ func TestEtcdUpdateController(t *testing.T) {
|
||||
key, _ := makeControllerKey(ctx, "foo")
|
||||
resp, _ := fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.UpdateController(ctx, &api.ReplicationController{
|
||||
_, err := registry.UpdateController(ctx, &api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: strconv.FormatUint(resp.Node.ModifiedIndex, 10)},
|
||||
Spec: api.ReplicationControllerSpec{
|
||||
Replicas: 2,
|
||||
@@ -417,7 +417,7 @@ func TestEtcdCreateService(t *testing.T) {
|
||||
ctx := api.NewDefaultContext()
|
||||
fakeClient := tools.NewFakeEtcdClient(t)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateService(ctx, &api.Service{
|
||||
_, err := registry.CreateService(ctx, &api.Service{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -447,7 +447,7 @@ func TestEtcdCreateServiceAlreadyExisting(t *testing.T) {
|
||||
key, _ := makeServiceKey(ctx, "foo")
|
||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}}), 0)
|
||||
registry := NewTestEtcdRegistry(fakeClient)
|
||||
err := registry.CreateService(ctx, &api.Service{
|
||||
_, err := registry.CreateService(ctx, &api.Service{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
})
|
||||
if !errors.IsAlreadyExists(err) {
|
||||
@@ -572,7 +572,7 @@ func TestEtcdUpdateService(t *testing.T) {
|
||||
SessionAffinity: "None",
|
||||
},
|
||||
}
|
||||
err := registry.UpdateService(ctx, &testService)
|
||||
_, err := registry.UpdateService(ctx, &testService)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user