mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 05:02:50 +00:00
Rename ID -> Name
This commit is contained in:
@@ -65,7 +65,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("not an endpoints: %#v", obj)
|
||||
}
|
||||
if len(endpoints.ID) == 0 {
|
||||
if len(endpoints.Name) == 0 {
|
||||
return nil, fmt.Errorf("id is required: %#v", obj)
|
||||
}
|
||||
endpoints.CreationTimestamp = util.Now()
|
||||
@@ -74,7 +74,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rs.registry.GetEndpoints(ctx, endpoints.ID)
|
||||
return rs.registry.GetEndpoints(ctx, endpoints.Name)
|
||||
}), nil
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rs.registry.GetEndpoints(ctx, endpoints.ID)
|
||||
return rs.registry.GetEndpoints(ctx, endpoints.Name)
|
||||
}), nil
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ import (
|
||||
func TestGetEndpoints(t *testing.T) {
|
||||
registry := ®istrytest.ServiceRegistry{
|
||||
Endpoints: api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"127.0.0.1:9000"},
|
||||
},
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func TestGetEndpointsMissingService(t *testing.T) {
|
||||
// returns empty endpoints
|
||||
registry.Err = nil
|
||||
registry.Service = &api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
}
|
||||
obj, err := storage.Get(ctx, "foo")
|
||||
if err != nil {
|
||||
@@ -76,8 +76,8 @@ func TestEndpointsRegistryList(t *testing.T) {
|
||||
registry.EndpointsList = api.EndpointsList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "1"},
|
||||
Items: []api.Endpoints{
|
||||
{TypeMeta: api.TypeMeta{ID: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{ID: "bar"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "foo"}},
|
||||
{TypeMeta: api.TypeMeta{Name: "bar"}},
|
||||
},
|
||||
}
|
||||
ctx := api.NewContext()
|
||||
@@ -86,10 +86,10 @@ func TestEndpointsRegistryList(t *testing.T) {
|
||||
if len(sl.Items) != 2 {
|
||||
t.Fatalf("Expected 2 endpoints, but got %v", len(sl.Items))
|
||||
}
|
||||
if e, a := "foo", sl.Items[0].ID; e != a {
|
||||
if e, a := "foo", sl.Items[0].Name; e != a {
|
||||
t.Errorf("Expected %v, but got %v", e, a)
|
||||
}
|
||||
if e, a := "bar", sl.Items[1].ID; e != a {
|
||||
if e, a := "bar", sl.Items[1].Name; e != a {
|
||||
t.Errorf("Expected %v, but got %v", e, a)
|
||||
}
|
||||
if sl.ResourceVersion != "1" {
|
||||
|
Reference in New Issue
Block a user