Rename ID -> Name

This commit is contained in:
Clayton Coleman
2014-10-22 13:02:02 -04:00
parent bdebff5b28
commit bb77a5d15f
107 changed files with 777 additions and 777 deletions

View File

@@ -32,7 +32,7 @@ func TestMakeBoundPodNoServices(t *testing.T) {
}
pod, err := factory.MakeBoundPod("machine", &api.Pod{
TypeMeta: api.TypeMeta{ID: "foobar"},
TypeMeta: api.TypeMeta{Name: "foobar"},
DesiredState: api.PodState{
Manifest: api.ContainerManifest{
Containers: []api.Container{
@@ -51,8 +51,8 @@ func TestMakeBoundPodNoServices(t *testing.T) {
if len(container.Env) != 0 {
t.Errorf("Expected zero env vars, got: %#v", pod)
}
if pod.ID != "foobar" {
t.Errorf("Failed to assign ID to pod: %#v", pod.ID)
if pod.Name != "foobar" {
t.Errorf("Failed to assign ID to pod: %#v", pod.Name)
}
}
@@ -61,7 +61,7 @@ func TestMakeBoundPodServices(t *testing.T) {
List: api.ServiceList{
Items: []api.Service{
{
TypeMeta: api.TypeMeta{ID: "test"},
TypeMeta: api.TypeMeta{Name: "test"},
Port: 8080,
ContainerPort: util.IntOrString{
Kind: util.IntstrInt,
@@ -137,7 +137,7 @@ func TestMakeBoundPodServicesExistingEnvVar(t *testing.T) {
List: api.ServiceList{
Items: []api.Service{
{
TypeMeta: api.TypeMeta{ID: "test"},
TypeMeta: api.TypeMeta{Name: "test"},
Port: 8080,
ContainerPort: util.IntOrString{
Kind: util.IntstrInt,

View File

@@ -94,12 +94,12 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context"))
}
pod.DesiredState.Manifest.UUID = uuid.NewUUID().String()
if len(pod.ID) == 0 {
pod.ID = pod.DesiredState.Manifest.UUID
if len(pod.Name) == 0 {
pod.Name = pod.DesiredState.Manifest.UUID
}
pod.DesiredState.Manifest.ID = pod.ID
pod.DesiredState.Manifest.ID = pod.Name
if errs := validation.ValidatePod(pod); len(errs) > 0 {
return nil, errors.NewInvalid("pod", pod.ID, errs)
return nil, errors.NewInvalid("pod", pod.Name, errs)
}
pod.CreationTimestamp = util.Now()
@@ -107,7 +107,7 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
if err := rs.registry.CreatePod(ctx, pod); err != nil {
return nil, err
}
return rs.registry.GetPod(ctx, pod.ID)
return rs.registry.GetPod(ctx, pod.Name)
}), nil
}
@@ -141,7 +141,7 @@ func (rs *REST) Get(ctx api.Context, id string) (runtime.Object, error) {
func (rs *REST) podToSelectableFields(pod *api.Pod) labels.Set {
return labels.Set{
"ID": pod.ID,
"ID": pod.Name,
"DesiredState.Status": string(pod.DesiredState.Status),
"DesiredState.Host": pod.DesiredState.Host,
}
@@ -190,13 +190,13 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan runtime.Obje
return nil, errors.NewConflict("pod", pod.Namespace, fmt.Errorf("Pod.Namespace does not match the provided context"))
}
if errs := validation.ValidatePod(pod); len(errs) > 0 {
return nil, errors.NewInvalid("pod", pod.ID, errs)
return nil, errors.NewInvalid("pod", pod.Name, errs)
}
return apiserver.MakeAsync(func() (runtime.Object, error) {
if err := rs.registry.UpdatePod(ctx, pod); err != nil {
return nil, err
}
return rs.registry.GetPod(ctx, pod.ID)
return rs.registry.GetPod(ctx, pod.Name)
}), nil
}
@@ -208,13 +208,13 @@ func (rs *REST) fillPodInfo(pod *api.Pod) {
// Get cached info for the list currently.
// TODO: Optionally use fresh info
if rs.podCache != nil {
info, err := rs.podCache.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.ID)
info, err := rs.podCache.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.Name)
if err != nil {
if err != client.ErrPodInfoNotAvailable {
glog.Errorf("Error getting container info from cache: %#v", err)
}
if rs.podInfoGetter != nil {
info, err = rs.podInfoGetter.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.ID)
info, err = rs.podInfoGetter.GetPodInfo(pod.CurrentState.Host, pod.Namespace, pod.Name)
}
if err != nil {
if err != client.ErrPodInfoNotAvailable {
@@ -232,7 +232,7 @@ func (rs *REST) fillPodInfo(pod *api.Pod) {
glog.Warningf("No network settings: %#v", netContainerInfo)
}
} else {
glog.Warningf("Couldn't find network container for %s in %v", pod.ID, info)
glog.Warningf("Couldn't find network container for %s in %v", pod.Name, info)
}
}
}
@@ -280,7 +280,7 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus,
}
found := false
for _, minion := range res.Items {
if minion.ID == pod.CurrentState.Host {
if minion.Name == pod.CurrentState.Host {
found = true
break
}

View File

@@ -95,10 +95,10 @@ func TestCreatePodSetsIds(t *testing.T) {
}
expectApiStatusError(t, ch, podRegistry.Err.Error())
if len(podRegistry.Pod.ID) == 0 {
if len(podRegistry.Pod.Name) == 0 {
t.Errorf("Expected pod ID to be set, Got %#v", pod)
}
if podRegistry.Pod.DesiredState.Manifest.ID != podRegistry.Pod.ID {
if podRegistry.Pod.DesiredState.Manifest.ID != podRegistry.Pod.Name {
t.Errorf("Expected manifest ID to be equal to pod ID, Got %#v", pod)
}
}
@@ -176,12 +176,12 @@ func TestListPodList(t *testing.T) {
Items: []api.Pod{
{
TypeMeta: api.TypeMeta{
ID: "foo",
Name: "foo",
},
},
{
TypeMeta: api.TypeMeta{
ID: "bar",
Name: "bar",
},
},
},
@@ -201,10 +201,10 @@ func TestListPodList(t *testing.T) {
if len(pods.Items) != 2 {
t.Errorf("Unexpected pod list: %#v", pods)
}
if pods.Items[0].ID != "foo" {
if pods.Items[0].Name != "foo" {
t.Errorf("Unexpected pod: %#v", pods.Items[0])
}
if pods.Items[1].ID != "bar" {
if pods.Items[1].Name != "bar" {
t.Errorf("Unexpected pod: %#v", pods.Items[1])
}
}
@@ -214,18 +214,18 @@ func TestListPodListSelection(t *testing.T) {
podRegistry.Pods = &api.PodList{
Items: []api.Pod{
{
TypeMeta: api.TypeMeta{ID: "foo"},
TypeMeta: api.TypeMeta{Name: "foo"},
}, {
TypeMeta: api.TypeMeta{ID: "bar"},
TypeMeta: api.TypeMeta{Name: "bar"},
DesiredState: api.PodState{Host: "barhost"},
}, {
TypeMeta: api.TypeMeta{ID: "baz"},
TypeMeta: api.TypeMeta{Name: "baz"},
DesiredState: api.PodState{Status: "bazstatus"},
}, {
TypeMeta: api.TypeMeta{ID: "qux"},
TypeMeta: api.TypeMeta{Name: "qux"},
Labels: map[string]string{"label": "qux"},
}, {
TypeMeta: api.TypeMeta{ID: "zot"},
TypeMeta: api.TypeMeta{Name: "zot"},
},
},
}
@@ -284,10 +284,10 @@ func TestListPodListSelection(t *testing.T) {
t.Errorf("%v: Expected %v, got %v", index, e, a)
}
for _, pod := range pods.Items {
if !item.expectedIDs.Has(pod.ID) {
t.Errorf("%v: Unexpected pod %v", index, pod.ID)
if !item.expectedIDs.Has(pod.Name) {
t.Errorf("%v: Unexpected pod %v", index, pod.Name)
}
t.Logf("%v: Got pod ID: %v", index, pod.ID)
t.Logf("%v: Got pod Name: %v", index, pod.Name)
}
}
}
@@ -299,7 +299,7 @@ func TestPodDecode(t *testing.T) {
}
expected := &api.Pod{
TypeMeta: api.TypeMeta{
ID: "foo",
Name: "foo",
},
}
body, err := latest.Codec.Encode(expected)
@@ -319,7 +319,7 @@ func TestPodDecode(t *testing.T) {
func TestGetPod(t *testing.T) {
podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}}
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}}
storage := REST{
registry: podRegistry,
ipCache: ipCache{},
@@ -340,7 +340,7 @@ func TestGetPod(t *testing.T) {
func TestGetPodCloud(t *testing.T) {
fakeCloud := &fake_cloud.FakeCloud{}
podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{ID: "foo"}, CurrentState: api.PodState{Host: "machine"}}
podRegistry.Pod = &api.Pod{TypeMeta: api.TypeMeta{Name: "foo"}, CurrentState: api.PodState{Host: "machine"}}
clock := &fakeClock{t: time.Now()}
@@ -386,7 +386,7 @@ func TestMakePodStatus(t *testing.T) {
Minions: api.MinionList{
Items: []api.Minion{
{
TypeMeta: api.TypeMeta{ID: "machine"},
TypeMeta: api.TypeMeta{Name: "machine"},
},
},
},
@@ -561,7 +561,7 @@ func TestPodStorageValidatesUpdate(t *testing.T) {
func TestCreatePod(t *testing.T) {
podRegistry := registrytest.NewPodRegistry(nil)
podRegistry.Pod = &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"},
TypeMeta: api.TypeMeta{Name: "foo"},
CurrentState: api.PodState{
Host: "machine",
},
@@ -576,7 +576,7 @@ func TestCreatePod(t *testing.T) {
},
}
pod := &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"},
TypeMeta: api.TypeMeta{Name: "foo"},
DesiredState: desiredState,
}
ctx := api.NewDefaultContext()
@@ -656,7 +656,7 @@ func TestFillPodInfoNoData(t *testing.T) {
func TestCreatePodWithConflictingNamespace(t *testing.T) {
storage := REST{}
pod := &api.Pod{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"},
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
}
ctx := api.NewDefaultContext()
@@ -674,7 +674,7 @@ func TestCreatePodWithConflictingNamespace(t *testing.T) {
func TestUpdatePodWithConflictingNamespace(t *testing.T) {
storage := REST{}
pod := &api.Pod{
TypeMeta: api.TypeMeta{ID: "test", Namespace: "not-default"},
TypeMeta: api.TypeMeta{Name: "test", Namespace: "not-default"},
}
ctx := api.NewDefaultContext()