mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 14:45:28 +00:00
Rename ID -> Name
This commit is contained in:
@@ -73,7 +73,7 @@ func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.Mini
|
||||
return result, err
|
||||
}
|
||||
for _, minion := range list.Items {
|
||||
status, err := health.DoHTTPCheck(r.makeMinionURL(minion.ID), r.client)
|
||||
status, err := health.DoHTTPCheck(r.makeMinionURL(minion.Name), r.client)
|
||||
if err != nil {
|
||||
glog.V(1).Infof("%#v failed health check with error: %s", minion, err)
|
||||
continue
|
||||
|
@@ -55,7 +55,7 @@ func TestBasicDelegation(t *testing.T) {
|
||||
t.Errorf("Expected %v, Got %v", mockMinionRegistry.Minions, list)
|
||||
}
|
||||
err = healthy.CreateMinion(ctx, &api.Minion{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
|
@@ -50,7 +50,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("not a minion: %#v", obj)
|
||||
}
|
||||
if minion.ID == "" {
|
||||
if minion.Name == "" {
|
||||
return nil, fmt.Errorf("ID should not be empty: %#v", minion)
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
minion, err := rs.registry.GetMinion(ctx, minion.ID)
|
||||
minion, err := rs.registry.GetMinion(ctx, minion.Name)
|
||||
if minion == nil {
|
||||
return nil, ErrDoesNotExist
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func (rs *REST) Update(ctx api.Context, minion runtime.Object) (<-chan runtime.O
|
||||
}
|
||||
|
||||
func (rs *REST) toApiMinion(name string) *api.Minion {
|
||||
return &api.Minion{TypeMeta: api.TypeMeta{ID: name}}
|
||||
return &api.Minion{TypeMeta: api.TypeMeta{Name: name}}
|
||||
}
|
||||
|
||||
// ResourceLocation returns a URL to which one can send traffic for the specified minion.
|
||||
@@ -117,7 +117,7 @@ func (rs *REST) ResourceLocation(ctx api.Context, id string) (string, error) {
|
||||
}
|
||||
host := minion.HostIP
|
||||
if host == "" {
|
||||
host = minion.ID
|
||||
host = minion.Name
|
||||
}
|
||||
// TODO: Minion webservers should be secure!
|
||||
return "http://" + net.JoinHostPort(host, strconv.Itoa(ports.KubeletPort)), nil
|
||||
|
@@ -27,25 +27,25 @@ import (
|
||||
func TestMinionREST(t *testing.T) {
|
||||
ms := NewREST(registrytest.NewMinionRegistry([]string{"foo", "bar"}, api.NodeResources{}))
|
||||
ctx := api.NewContext()
|
||||
if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Minion).ID != "foo" {
|
||||
if obj, err := ms.Get(ctx, "foo"); err != nil || obj.(*api.Minion).Name != "foo" {
|
||||
t.Errorf("missing expected object")
|
||||
}
|
||||
if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Minion).ID != "bar" {
|
||||
if obj, err := ms.Get(ctx, "bar"); err != nil || obj.(*api.Minion).Name != "bar" {
|
||||
t.Errorf("missing expected object")
|
||||
}
|
||||
if _, err := ms.Get(ctx, "baz"); err != ErrDoesNotExist {
|
||||
t.Errorf("has unexpected object")
|
||||
}
|
||||
|
||||
c, err := ms.Create(ctx, &api.Minion{TypeMeta: api.TypeMeta{ID: "baz"}})
|
||||
c, err := ms.Create(ctx, &api.Minion{TypeMeta: api.TypeMeta{Name: "baz"}})
|
||||
if err != nil {
|
||||
t.Errorf("insert failed")
|
||||
}
|
||||
obj := <-c
|
||||
if m, ok := obj.(*api.Minion); !ok || m.ID != "baz" {
|
||||
if m, ok := obj.(*api.Minion); !ok || m.Name != "baz" {
|
||||
t.Errorf("insert return value was weird: %#v", obj)
|
||||
}
|
||||
if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Minion).ID != "baz" {
|
||||
if obj, err := ms.Get(ctx, "baz"); err != nil || obj.(*api.Minion).Name != "baz" {
|
||||
t.Errorf("insert didn't actually insert")
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ func TestMinionREST(t *testing.T) {
|
||||
}
|
||||
expect := []api.Minion{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
}, {
|
||||
TypeMeta: api.TypeMeta{ID: "baz"},
|
||||
TypeMeta: api.TypeMeta{Name: "baz"},
|
||||
},
|
||||
}
|
||||
nodeList := list.(*api.MinionList)
|
||||
@@ -85,7 +85,7 @@ func TestMinionREST(t *testing.T) {
|
||||
|
||||
func contains(nodes *api.MinionList, nodeID string) bool {
|
||||
for _, node := range nodes.Items {
|
||||
if node.ID == nodeID {
|
||||
if node.Name == nodeID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user