diff --git a/cmd/localkube/localkube.go b/cmd/localkube/localkube.go index ab65f21dd0a..a7a0f89f6e6 100644 --- a/cmd/localkube/localkube.go +++ b/cmd/localkube/localkube.go @@ -23,7 +23,7 @@ import ( "flag" "fmt" "log" - "math/rand" + "math/rand" "net/http" "os" "time" @@ -91,8 +91,8 @@ func api_server() { Client: http.DefaultClient, Port: *kubelet_port, } - random := rand.New(rand.NewSource(int64(time.Now().Nanosecond()))) - + random := rand.New(rand.NewSource(int64(time.Now().Nanosecond()))) + storage := map[string]apiserver.RESTStorage{ "pods": registry.MakePodRegistryStorage(podRegistry, containerInfo, registry.MakeFirstFitScheduler(machineList, podRegistry, random)), "replicationControllers": registry.MakeControllerRegistryStorage(controllerRegistry), diff --git a/pkg/apiserver/api_server_test.go b/pkg/apiserver/api_server_test.go index 03e7b9beced..1e6a6f39fea 100644 --- a/pkg/apiserver/api_server_test.go +++ b/pkg/apiserver/api_server_test.go @@ -127,7 +127,7 @@ func TestNonEmptyList(t *testing.T) { storage := map[string]RESTStorage{} simpleStorage := SimpleRESTStorage{ list: []Simple{ - Simple{ + { Name: "foo", }, }, diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index d2cbc749cfc..ecd4dd4ea3d 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -63,7 +63,7 @@ func TestListEmptyPods(t *testing.T) { func TestListPods(t *testing.T) { expectedPodList := api.PodList{ Items: []api.Pod{ - api.Pod{ + { CurrentState: api.PodState{ Status: "Foobar", }, @@ -97,7 +97,7 @@ func TestListPods(t *testing.T) { func TestListPodsLabels(t *testing.T) { expectedPodList := api.PodList{ Items: []api.Pod{ - api.Pod{ + { CurrentState: api.PodState{ Status: "Foobar", }, diff --git a/pkg/cloudcfg/cloudcfg.go b/pkg/cloudcfg/cloudcfg.go index 7cdedc86931..0245fe5f7ef 100644 --- a/pkg/cloudcfg/cloudcfg.go +++ b/pkg/cloudcfg/cloudcfg.go @@ -189,7 +189,7 @@ func RunController(image, name string, replicas int, client client.ClientInterfa DesiredState: api.PodState{ Manifest: api.ContainerManifest{ Containers: []api.Container{ - api.Container{ + { Image: image, Ports: makePorts(portSpec), }, diff --git a/pkg/cloudcfg/cloudcfg_test.go b/pkg/cloudcfg/cloudcfg_test.go index a80811991bf..04dd8dd800a 100644 --- a/pkg/cloudcfg/cloudcfg_test.go +++ b/pkg/cloudcfg/cloudcfg_test.go @@ -120,8 +120,8 @@ func TestUpdateWithPods(t *testing.T) { client := FakeKubeClient{ pods: PodList{ Items: []Pod{ - Pod{JSONBase: JSONBase{ID: "pod-1"}}, - Pod{JSONBase: JSONBase{ID: "pod-2"}}, + {JSONBase: JSONBase{ID: "pod-1"}}, + {JSONBase: JSONBase{ID: "pod-2"}}, }, }, } diff --git a/pkg/cloudcfg/resource_printer.go b/pkg/cloudcfg/resource_printer.go index 5ad9fb7c14b..7f732edc70e 100644 --- a/pkg/cloudcfg/resource_printer.go +++ b/pkg/cloudcfg/resource_printer.go @@ -58,7 +58,7 @@ func (h *HumanReadablePrinter) printHeader(columnNames []string, w io.Writer) er return err } var lines []string - for _, _ = range columnNames { + for _ = range columnNames { lines = append(lines, "----------") } _, err := fmt.Fprintf(w, "%s\n", strings.Join(lines, "\t")) diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 9f88df109d3..627439d98fd 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -270,7 +270,7 @@ func (kl *Kubelet) RunContainer(manifest *api.ContainerManifest, container *api. dockerPort := docker.Port(strconv.Itoa(interiorPort) + "/tcp") exposedPorts[dockerPort] = struct{}{} portBindings[dockerPort] = []docker.PortBinding{ - docker.PortBinding{ + { HostPort: strconv.Itoa(exteriorPort), }, } diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index e4adc8b5d34..5f73b32ab64 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -172,10 +172,10 @@ func TestContainerExists(t *testing.T) { Name: "foo", } fakeDocker.containerList = []docker.APIContainers{ - docker.APIContainers{ + { Names: []string{"foo--qux--1234"}, }, - docker.APIContainers{ + { Names: []string{"bar--qux--1234"}, }, } @@ -201,11 +201,11 @@ func TestGetContainerID(t *testing.T) { DockerClient: &fakeDocker, } fakeDocker.containerList = []docker.APIContainers{ - docker.APIContainers{ + { Names: []string{"foo"}, ID: "1234", }, - docker.APIContainers{ + { Names: []string{"bar"}, ID: "4567", }, @@ -236,10 +236,10 @@ func TestGetContainerByName(t *testing.T) { DockerClient: &fakeDocker, } fakeDocker.containerList = []docker.APIContainers{ - docker.APIContainers{ + { Names: []string{"foo"}, }, - docker.APIContainers{ + { Names: []string{"bar"}, }, } @@ -264,10 +264,10 @@ func TestListContainers(t *testing.T) { DockerClient: &fakeDocker, } fakeDocker.containerList = []docker.APIContainers{ - docker.APIContainers{ + { Names: []string{"foo"}, }, - docker.APIContainers{ + { Names: []string{"bar"}, }, } @@ -282,10 +282,10 @@ func TestKillContainerWithError(t *testing.T) { fakeDocker := FakeDockerClient{ err: fmt.Errorf("Sample Error"), containerList: []docker.APIContainers{ - docker.APIContainers{ + { Names: []string{"foo"}, }, - docker.APIContainers{ + { Names: []string{"bar"}, }, }, @@ -306,10 +306,10 @@ func TestKillContainer(t *testing.T) { DockerClient: &fakeDocker, } fakeDocker.containerList = []docker.APIContainers{ - docker.APIContainers{ + { Names: []string{"foo"}, }, - docker.APIContainers{ + { Names: []string{"bar"}, }, } @@ -325,11 +325,11 @@ func TestKillContainer(t *testing.T) { func TestSyncHTTP(t *testing.T) { containers := api.ContainerManifest{ Containers: []api.Container{ - api.Container{ + { Name: "foo", Image: "dockerfile/foo", }, - api.Container{ + { Name: "bar", Image: "dockerfile/bar", }, @@ -374,8 +374,8 @@ func TestResponseToManifests(t *testing.T) { list, err := kubelet.ResponseToManifests(&etcd.Response{ Node: &etcd.Node{ Value: util.MakeJSONString([]api.ContainerManifest{ - api.ContainerManifest{Id: "foo"}, - api.ContainerManifest{Id: "bar"}, + {Id: "foo"}, + {Id: "bar"}, }), }, }) @@ -508,7 +508,7 @@ func TestSyncManifestsDoesNothing(t *testing.T) { err: nil, } fakeDocker.containerList = []docker.APIContainers{ - docker.APIContainers{ + { // format is -- Names: []string{"bar--foo"}, ID: "1234", @@ -521,10 +521,10 @@ func TestSyncManifestsDoesNothing(t *testing.T) { DockerClient: &fakeDocker, } err := kubelet.SyncManifests([]api.ContainerManifest{ - api.ContainerManifest{ + { Id: "foo", Containers: []api.Container{ - api.Container{Name: "bar"}, + {Name: "bar"}, }, }, }) @@ -543,7 +543,7 @@ func TestSyncManifestsDeletes(t *testing.T) { err: nil, } fakeDocker.containerList = []docker.APIContainers{ - docker.APIContainers{ + { Names: []string{"foo"}, ID: "1234", }, diff --git a/pkg/proxy/config/etcd.go b/pkg/proxy/config/etcd.go index beeb6ba0934..f3326278825 100644 --- a/pkg/proxy/config/etcd.go +++ b/pkg/proxy/config/etcd.go @@ -205,7 +205,7 @@ func (impl ConfigSourceEtcd) ProcessChange(response *etcd.Response) { parts := strings.Split(response.Node.Key[1:], "/") if len(parts) == 4 { log.Printf("Deleting service: %s", parts[3]) - serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{api.Service{JSONBase: api.JSONBase{ID: parts[3]}}}} + serviceUpdate := ServiceUpdate{Op: REMOVE, Services: []api.Service{{JSONBase: api.JSONBase{ID: parts[3]}}}} impl.serviceChannel <- serviceUpdate return } else { diff --git a/pkg/registry/controller_registry_test.go b/pkg/registry/controller_registry_test.go index 9df4bc524e3..7580484a640 100644 --- a/pkg/registry/controller_registry_test.go +++ b/pkg/registry/controller_registry_test.go @@ -81,12 +81,12 @@ func TestListEmptyControllerList(t *testing.T) { func TestListControllerList(t *testing.T) { mockRegistry := MockControllerRegistry{ controllers: []ReplicationController{ - ReplicationController{ + { JSONBase: JSONBase{ ID: "foo", }, }, - ReplicationController{ + { JSONBase: JSONBase{ ID: "bar", }, @@ -145,10 +145,10 @@ func TestControllerParsing(t *testing.T) { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Image: "dockerfile/nginx", Ports: []Port{ - Port{ + { ContainerPort: 80, HostPort: 8080, }, diff --git a/pkg/registry/endpoints_test.go b/pkg/registry/endpoints_test.go index 918c5344688..729c19a51ed 100644 --- a/pkg/registry/endpoints_test.go +++ b/pkg/registry/endpoints_test.go @@ -48,7 +48,7 @@ func TestSyncEndpointsItems(t *testing.T) { serviceRegistry := MockServiceRegistry{ list: ServiceList{ Items: []Service{ - Service{ + { Labels: map[string]string{ "foo": "bar", }, @@ -58,13 +58,13 @@ func TestSyncEndpointsItems(t *testing.T) { } podRegistry := MockPodRegistry{ pods: []Pod{ - Pod{ + { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Ports: []Port{ - Port{ + { HostPort: 8080, }, }, @@ -88,7 +88,7 @@ func TestSyncEndpointsPodError(t *testing.T) { serviceRegistry := MockServiceRegistry{ list: ServiceList{ Items: []Service{ - Service{ + { Labels: map[string]string{ "foo": "bar", }, diff --git a/pkg/registry/etcd_registry_test.go b/pkg/registry/etcd_registry_test.go index 0237dd1400c..51779fe2d5f 100644 --- a/pkg/registry/etcd_registry_test.go +++ b/pkg/registry/etcd_registry_test.go @@ -70,7 +70,7 @@ func TestEtcdCreatePod(t *testing.T) { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Name: "foo", }, }, @@ -171,7 +171,7 @@ func TestEtcdCreatePodWithContainersNotFound(t *testing.T) { Manifest: ContainerManifest{ Id: "foo", Containers: []Container{ - Container{ + { Name: "foo", }, }, @@ -205,7 +205,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { E: &etcd.EtcdError{ErrorCode: 100}, } fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{ - ContainerManifest{ + { Id: "bar", }, }), 0) @@ -218,7 +218,7 @@ func TestEtcdCreatePodWithExistingContainers(t *testing.T) { Manifest: ContainerManifest{ Id: "foo", Containers: []Container{ - Container{ + { Name: "foo", }, }, @@ -248,7 +248,7 @@ func TestEtcdDeletePod(t *testing.T) { key := "/registry/hosts/machine/pods/foo" fakeClient.Set(key, util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}), 0) fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{ - ContainerManifest{ + { Id: "foo", }, }), 0) @@ -272,8 +272,8 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) { key := "/registry/hosts/machine/pods/foo" fakeClient.Set(key, util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}), 0) fakeClient.Set("/registry/hosts/machine/kubelet", util.MakeJSONString([]ContainerManifest{ - ContainerManifest{Id: "foo"}, - ContainerManifest{Id: "bar"}, + {Id: "foo"}, + {Id: "bar"}, }), 0) registry := MakeTestEtcdRegistry(fakeClient, []string{"machine"}) err := registry.DeletePod("foo") @@ -336,10 +336,10 @@ func TestEtcdListPods(t *testing.T) { R: &etcd.Response{ Node: &etcd.Node{ Nodes: []*etcd.Node{ - &etcd.Node{ + { Value: util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "foo"}}), }, - &etcd.Node{ + { Value: util.MakeJSONString(Pod{JSONBase: JSONBase{ID: "bar"}}), }, }, @@ -392,10 +392,10 @@ func TestEtcdListControllers(t *testing.T) { R: &etcd.Response{ Node: &etcd.Node{ Nodes: []*etcd.Node{ - &etcd.Node{ + { Value: util.MakeJSONString(ReplicationController{JSONBase: JSONBase{ID: "foo"}}), }, - &etcd.Node{ + { Value: util.MakeJSONString(ReplicationController{JSONBase: JSONBase{ID: "bar"}}), }, }, @@ -499,10 +499,10 @@ func TestEtcdListServices(t *testing.T) { R: &etcd.Response{ Node: &etcd.Node{ Nodes: []*etcd.Node{ - &etcd.Node{ + { Value: util.MakeJSONString(Service{JSONBase: JSONBase{ID: "foo"}}), }, - &etcd.Node{ + { Value: util.MakeJSONString(Service{JSONBase: JSONBase{ID: "bar"}}), }, }, diff --git a/pkg/registry/manifest_factory_test.go b/pkg/registry/manifest_factory_test.go index 026fc691f73..b2eb01b0911 100644 --- a/pkg/registry/manifest_factory_test.go +++ b/pkg/registry/manifest_factory_test.go @@ -32,7 +32,7 @@ func TestMakeManifestNoServices(t *testing.T) { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Name: "foo", }, }, @@ -55,7 +55,7 @@ func TestMakeManifestServices(t *testing.T) { registry := MockServiceRegistry{ list: ServiceList{ Items: []Service{ - Service{ + { JSONBase: JSONBase{ID: "test"}, Port: 8080, }, @@ -70,7 +70,7 @@ func TestMakeManifestServices(t *testing.T) { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Name: "foo", }, }, @@ -92,7 +92,7 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) { registry := MockServiceRegistry{ list: ServiceList{ Items: []Service{ - Service{ + { JSONBase: JSONBase{ID: "test"}, Port: 8080, }, @@ -107,9 +107,9 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Env: []EnvVar{ - EnvVar{ + { Name: "foo", Value: "bar", }, diff --git a/pkg/registry/memory_registry.go b/pkg/registry/memory_registry.go index 3a3e8321409..ca9bd9a1a09 100644 --- a/pkg/registry/memory_registry.go +++ b/pkg/registry/memory_registry.go @@ -22,14 +22,14 @@ import ( // An implementation of PodRegistry and ControllerRegistry that is backed by memory // Mainly used for testing. type MemoryRegistry struct { - podData map[string]Pod + podData map[string]Pod controllerData map[string]ReplicationController serviceData map[string]Service } func MakeMemoryRegistry() *MemoryRegistry { return &MemoryRegistry{ - podData: map[string]Pod{}, + podData: map[string]Pod{}, controllerData: map[string]ReplicationController{}, serviceData: map[string]Service{}, } diff --git a/pkg/registry/pod_registry_test.go b/pkg/registry/pod_registry_test.go index c5bfc4d4ea6..1630ca8eb55 100644 --- a/pkg/registry/pod_registry_test.go +++ b/pkg/registry/pod_registry_test.go @@ -85,12 +85,12 @@ func TestListEmptyPodList(t *testing.T) { func TestListPodList(t *testing.T) { mockRegistry := MockPodRegistry{ pods: []Pod{ - Pod{ + { JSONBase: JSONBase{ ID: "foo", }, }, - Pod{ + { JSONBase: JSONBase{ ID: "bar", }, diff --git a/pkg/registry/replication_controller_test.go b/pkg/registry/replication_controller_test.go index 6cbfd74cbf8..f1997b0c8b2 100644 --- a/pkg/registry/replication_controller_test.go +++ b/pkg/registry/replication_controller_test.go @@ -37,7 +37,7 @@ func makeUrl(suffix string) string { type FakePodControl struct { controllerSpec []ReplicationController - deletePodID []string + deletePodID []string } func (f *FakePodControl) createReplica(spec ReplicationController) { @@ -57,7 +57,7 @@ func makeReplicationController(replicas int) ReplicationController { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Image: "foo/bar", }, }, @@ -182,7 +182,7 @@ func TestCreateReplica(t *testing.T) { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Image: "foo/bar", }, }, diff --git a/pkg/registry/scheduler.go b/pkg/registry/scheduler.go index 377e5d06a04..5153c763d05 100644 --- a/pkg/registry/scheduler.go +++ b/pkg/registry/scheduler.go @@ -73,7 +73,7 @@ func MakeFirstFitScheduler(machines []string, registry PodRegistry, random *rand return &FirstFitScheduler{ machines: machines, registry: registry, - random: random, + random: random, } } diff --git a/pkg/registry/scheduler_test.go b/pkg/registry/scheduler_test.go index f94d8b1adfe..8ce7e8dec91 100644 --- a/pkg/registry/scheduler_test.go +++ b/pkg/registry/scheduler_test.go @@ -64,7 +64,7 @@ func makePod(host string, hostPorts ...int) Pod { DesiredState: PodState{ Manifest: ContainerManifest{ Containers: []Container{ - Container{ + { Ports: networkPorts, }, },