Merge pull request #84 from proppy/gofmt

gofmt -s pkg/ cmd/
pull/6/head
Daniel Smith 2014-06-12 14:20:12 -07:00
commit 54d1e7e86d
18 changed files with 69 additions and 69 deletions

View File

@ -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),

View File

@ -127,7 +127,7 @@ func TestNonEmptyList(t *testing.T) {
storage := map[string]RESTStorage{}
simpleStorage := SimpleRESTStorage{
list: []Simple{
Simple{
{
Name: "foo",
},
},

View File

@ -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",
},

View File

@ -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),
},

View File

@ -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"}},
},
},
}

View File

@ -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"))

View File

@ -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),
},
}

View File

@ -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 <container-id>--<manifest-id>
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",
},

View File

@ -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 {

View File

@ -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,
},

View File

@ -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",
},

View File

@ -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"}}),
},
},

View File

@ -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",
},

View File

@ -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{},
}

View File

@ -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",
},

View File

@ -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",
},
},

View File

@ -73,7 +73,7 @@ func MakeFirstFitScheduler(machines []string, registry PodRegistry, random *rand
return &FirstFitScheduler{
machines: machines,
registry: registry,
random: random,
random: random,
}
}

View File

@ -64,7 +64,7 @@ func makePod(host string, hostPorts ...int) Pod {
DesiredState: PodState{
Manifest: ContainerManifest{
Containers: []Container{
Container{
{
Ports: networkPorts,
},
},