diff --git a/pkg/api/types.go b/pkg/api/types.go index ed18f287678..f7786b38eab 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -23,7 +23,7 @@ type ContainerManifest struct { Version string `yaml:"version" json:"version"` Volumes []Volume `yaml:"volumes" json:"volumes"` Containers []Container `yaml:"containers" json:"containers"` - Id string `yaml:"id,omitempty" json:"id,omitempty"` + ID string `yaml:"id,omitempty" json:"id,omitempty"` } // Volume represents a named volume in a pod that may be accessed by any containers in the pod. diff --git a/pkg/kubecfg/parse_test.go b/pkg/kubecfg/parse_test.go index 12d6a33c0db..710f867f513 100644 --- a/pkg/kubecfg/parse_test.go +++ b/pkg/kubecfg/parse_test.go @@ -59,7 +59,7 @@ func TestParsePod(t *testing.T) { JSONBase: api.JSONBase{ID: "test pod"}, DesiredState: api.PodState{ Manifest: api.ContainerManifest{ - Id: "My manifest", + ID: "My manifest", Containers: []api.Container{ {Name: "my container"}, }, @@ -91,7 +91,7 @@ func TestParseController(t *testing.T) { PodTemplate: api.PodTemplate{ DesiredState: api.PodState{ Manifest: api.ContainerManifest{ - Id: "My manifest", + ID: "My manifest", Containers: []api.Container{ {Name: "my container"}, }, diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 06714cd12d4..f2c54e2e3b0 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -198,7 +198,7 @@ func (kl *Kubelet) getContainerId(manifest *api.ContainerManifest, container *ap } for id, dockerContainer := range dockerContainers { manifestId, containerName := parseDockerName(dockerContainer.Names[0]) - if manifestId == manifest.Id && containerName == container.Name { + if manifestId == manifest.ID && containerName == container.Name { return DockerId(id), nil } } @@ -247,8 +247,8 @@ const containerNamePrefix = "k8s" // Creates a name which can be reversed to identify both manifest id and container name. func buildDockerName(manifest *api.ContainerManifest, container *api.Container) string { - // Note, manifest.Id could be blank. - return fmt.Sprintf("%s--%s--%s--%08x", containerNamePrefix, escapeDash(container.Name), escapeDash(manifest.Id), rand.Uint32()) + // Note, manifest.ID could be blank. + return fmt.Sprintf("%s--%s--%s--%08x", containerNamePrefix, escapeDash(container.Name), escapeDash(manifest.ID), rand.Uint32()) } // Upacks a container name, returning the manifest id and container name we would have used to @@ -367,7 +367,7 @@ func (kl *Kubelet) killContainer(container docker.APIContainers) error { kl.LogEvent(&api.Event{ Event: "STOP", Manifest: &api.ContainerManifest{ - Id: manifestId, + ID: manifestId, }, Container: &api.Container{ Name: containerName, @@ -650,14 +650,14 @@ func (kl *Kubelet) SyncManifests(config []api.ContainerManifest) error { // Make sure we have a network container netId, err := kl.getNetworkContainerId(&manifest) if err != nil { - glog.Errorf("Failed to introspect network container. (%v) Skipping container %s", err, manifest.Id) + glog.Errorf("Failed to introspect network container. (%v) Skipping container %s", err, manifest.ID) continue } if netId == "" { glog.Infof("Network container doesn't exist, creating") netId, err = kl.createNetworkContainer(&manifest) if err != nil { - glog.Errorf("Failed to create network container: %v Skipping container %s", err, manifest.Id) + glog.Errorf("Failed to create network container: %v Skipping container %s", err, manifest.ID) continue } } diff --git a/pkg/kubelet/kubelet_server_test.go b/pkg/kubelet/kubelet_server_test.go index c52ba621743..22891e2a42f 100644 --- a/pkg/kubelet/kubelet_server_test.go +++ b/pkg/kubelet/kubelet_server_test.go @@ -74,7 +74,7 @@ func readResp(resp *http.Response) (string, error) { func TestContainer(t *testing.T) { fw := makeServerTest() expected := []api.ContainerManifest{ - {Id: "test_manifest"}, + {ID: "test_manifest"}, } body := bytes.NewBuffer([]byte(util.MakeJSONString(expected[0]))) // Only send a single ContainerManifest resp, err := http.Post(fw.testHttpServer.URL+"/container", "application/json", body) @@ -95,8 +95,8 @@ func TestContainer(t *testing.T) { func TestContainers(t *testing.T) { fw := makeServerTest() expected := []api.ContainerManifest{ - {Id: "test_manifest_1"}, - {Id: "test_manifest_2"}, + {ID: "test_manifest_1"}, + {ID: "test_manifest_2"}, } body := bytes.NewBuffer([]byte(util.MakeJSONString(expected))) resp, err := http.Post(fw.testHttpServer.URL+"/containers", "application/json", body) diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 12fa048a502..1afd3e4c678 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -110,7 +110,7 @@ func verifyStringArrayEquals(t *testing.T, actual, expected []string) { func verifyPackUnpack(t *testing.T, manifestId, containerName string) { name := buildDockerName( - &api.ContainerManifest{Id: manifestId}, + &api.ContainerManifest{ID: manifestId}, &api.Container{Name: containerName}, ) returnedManifestId, returnedContainerName := parseDockerName(name) @@ -142,7 +142,7 @@ func TestGetContainerId(t *testing.T) { DockerPuller: &FakeDockerPuller{}, } manifest := api.ContainerManifest{ - Id: "qux", + ID: "qux", } container := api.Container{ Name: "foo", @@ -171,7 +171,7 @@ func TestGetContainerId(t *testing.T) { } fakeDocker.clearCalls() - missingManifest := api.ContainerManifest{Id: "foobar"} + missingManifest := api.ContainerManifest{ID: "foobar"} id, err = kubelet.getContainerId(&missingManifest, &container) verifyCalls(t, fakeDocker, []string{"list"}) if id != "" { @@ -245,12 +245,12 @@ func TestResponseToManifests(t *testing.T) { list, err := kubelet.ResponseToManifests(&etcd.Response{ Node: &etcd.Node{ Value: util.MakeJSONString([]api.ContainerManifest{ - {Id: "foo"}, - {Id: "bar"}, + {ID: "foo"}, + {ID: "bar"}, }), }, }) - if len(list) != 2 || list[0].Id != "foo" || list[1].Id != "bar" { + if len(list) != 2 || list[0].ID != "foo" || list[1].ID != "bar" { t.Errorf("Unexpected list: %#v", list) } expectNoError(t, err) @@ -399,7 +399,7 @@ func TestSyncManifestsDoesNothing(t *testing.T) { } err := kubelet.SyncManifests([]api.ContainerManifest{ { - Id: "foo", + ID: "foo", Containers: []api.Container{ {Name: "bar"}, }, @@ -639,7 +639,7 @@ func TestExtractFromBadDataFile(t *testing.T) { func TestExtractFromValidDataFile(t *testing.T) { kubelet := Kubelet{} - manifest := api.ContainerManifest{Id: "bar"} + manifest := api.ContainerManifest{ID: "bar"} data, err := json.Marshal(manifest) expectNoError(t, err) file, err := ioutil.TempFile("", "foo") @@ -669,8 +669,8 @@ func TestExtractFromDir(t *testing.T) { kubelet := Kubelet{} manifests := []api.ContainerManifest{ - {Id: "aaaa"}, - {Id: "bbbb"}, + {ID: "aaaa"}, + {ID: "bbbb"}, } dirName, err := ioutil.TempDir("", "foo") @@ -679,7 +679,7 @@ func TestExtractFromDir(t *testing.T) { for _, manifest := range manifests { data, err := json.Marshal(manifest) expectNoError(t, err) - file, err := ioutil.TempFile(dirName, manifest.Id) + file, err := ioutil.TempFile(dirName, manifest.ID) expectNoError(t, err) name := file.Name() expectNoError(t, file.Close()) @@ -716,7 +716,7 @@ func TestExtractFromHttpSingle(t *testing.T) { reader := startReading(updateChannel) manifests := []api.ContainerManifest{ - {Version: "v1beta1", Id: "foo"}, + {Version: "v1beta1", ID: "foo"}, } // Taking a single-manifest from a URL allows kubelet to be used // in the implementation of google's container VM image. @@ -751,8 +751,8 @@ func TestExtractFromHttpMultiple(t *testing.T) { reader := startReading(updateChannel) manifests := []api.ContainerManifest{ - {Version: "v1beta1", Id: "foo"}, - {Version: "v1beta1", Id: "bar"}, + {Version: "v1beta1", ID: "foo"}, + {Version: "v1beta1", ID: "bar"}, } data, err := json.Marshal(manifests) if err != nil { @@ -828,7 +828,7 @@ func TestWatchEtcd(t *testing.T) { manifest := []api.ContainerManifest{ { - Id: "foo", + ID: "foo", }, } data, err := json.Marshal(manifest) diff --git a/pkg/registry/etcd_registry.go b/pkg/registry/etcd_registry.go index 162d62c61ba..9f8c95aa82e 100644 --- a/pkg/registry/etcd_registry.go +++ b/pkg/registry/etcd_registry.go @@ -150,7 +150,7 @@ func (registry *EtcdRegistry) deletePodFromMachine(machine, podID string) error newManifests := make([]api.ContainerManifest, 0, len(manifests)) found := false for _, manifest := range manifests { - if manifest.Id != podID { + if manifest.ID != podID { newManifests = append(newManifests, manifest) } else { found = true diff --git a/pkg/registry/etcd_registry_test.go b/pkg/registry/etcd_registry_test.go index 2fe21a79b59..1ea19adf51f 100644 --- a/pkg/registry/etcd_registry_test.go +++ b/pkg/registry/etcd_registry_test.go @@ -100,7 +100,7 @@ func TestEtcdCreatePod(t *testing.T) { resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) expectNoError(t, err) err = json.Unmarshal([]byte(resp.Node.Value), &manifests) - if len(manifests) != 1 || manifests[0].Id != "foo" { + if len(manifests) != 1 || manifests[0].ID != "foo" { t.Errorf("Unexpected manifest list: %#v", manifests) } } @@ -179,7 +179,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) { }, DesiredState: api.PodState{ Manifest: api.ContainerManifest{ - Id: "foo", + ID: "foo", Containers: []api.Container{ { Name: "foo", @@ -201,7 +201,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) { resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) expectNoError(t, err) err = json.Unmarshal([]byte(resp.Node.Value), &manifests) - if len(manifests) != 1 || manifests[0].Id != "foo" { + if len(manifests) != 1 || manifests[0].ID != "foo" { t.Errorf("Unexpected manifest list: %#v", manifests) } } @@ -216,7 +216,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { } fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]api.ContainerManifest{ { - Id: "bar", + ID: "bar", }, }), 0) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) @@ -226,7 +226,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { }, DesiredState: api.PodState{ Manifest: api.ContainerManifest{ - Id: "foo", + ID: "foo", Containers: []api.Container{ { Name: "foo", @@ -248,7 +248,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { resp, err = fakeClient.Get("/registry/hosts/machine/kubelet", false, false) expectNoError(t, err) err = json.Unmarshal([]byte(resp.Node.Value), &manifests) - if len(manifests) != 2 || manifests[1].Id != "foo" { + if len(manifests) != 2 || manifests[1].ID != "foo" { t.Errorf("Unexpected manifest list: %#v", manifests) } } @@ -259,7 +259,7 @@ func TestEtcdDeletePod(t *testing.T) { fakeClient.Set(key, util.MakeJSONString(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0) fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]api.ContainerManifest{ { - Id: "foo", + ID: "foo", }, }), 0) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) @@ -281,8 +281,8 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { key := "/registry/hosts/machine/pods/foo" fakeClient.Set(key, util.MakeJSONString(api.Pod{JSONBase: api.JSONBase{ID: "foo"}}), 0) fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]api.ContainerManifest{ - {Id: "foo"}, - {Id: "bar"}, + {ID: "foo"}, + {ID: "bar"}, }), 0) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) err := registry.DeletePod("foo") @@ -299,7 +299,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { if len(manifests) != 1 { t.Errorf("Unexpected manifest set: %#v, expected empty", manifests) } - if manifests[0].Id != "bar" { + if manifests[0].ID != "bar" { t.Errorf("Deleted wrong manifest: %#v", manifests) } } diff --git a/pkg/registry/manifest_factory.go b/pkg/registry/manifest_factory.go index 120418cee8d..9f8cb19a598 100644 --- a/pkg/registry/manifest_factory.go +++ b/pkg/registry/manifest_factory.go @@ -35,7 +35,7 @@ func (b *BasicManifestFactory) MakeManifest(machine string, pod api.Pod) (api.Co return api.ContainerManifest{}, err } for ix, container := range pod.DesiredState.Manifest.Containers { - pod.DesiredState.Manifest.Id = pod.ID + pod.DesiredState.Manifest.ID = pod.ID pod.DesiredState.Manifest.Containers[ix].Env = append(container.Env, envVars...) } return pod.DesiredState.Manifest, nil diff --git a/pkg/registry/manifest_factory_test.go b/pkg/registry/manifest_factory_test.go index b956c373eab..a215106e437 100644 --- a/pkg/registry/manifest_factory_test.go +++ b/pkg/registry/manifest_factory_test.go @@ -47,7 +47,7 @@ func TestMakeManifestNoServices(t *testing.T) { container.Env[0].Value != "machine" { t.Errorf("Expected one env vars, got: %#v", manifest) } - if manifest.Id != "foobar" { + if manifest.ID != "foobar" { t.Errorf("Failed to assign id to manifest: %#v") } }