fix non-gofmt'd things

pull/6/head
Daniel Smith 2014-09-24 14:27:10 -07:00
parent 50eb2cf59c
commit bb0cd95a83
11 changed files with 147 additions and 147 deletions

View File

@ -22,6 +22,6 @@ package main
import (
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/aws"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/gce"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/vagrant"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/ovirt"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/vagrant"
)

View File

@ -85,7 +85,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
func TestInternalRoundTrip(t *testing.T) {
latest := "v1beta2"
for k, _ := range internal.Scheme.KnownTypes("") {
for k := range internal.Scheme.KnownTypes("") {
obj, err := internal.Scheme.New("", k)
if err != nil {
t.Errorf("%s: unexpected error: %v", k, err)

View File

@ -89,20 +89,20 @@ func mockInstancesResp(instances []ec2.Instance) (aws *AWSCloud) {
func(instanceIds []string, filter *ec2.Filter) (resp *ec2.InstancesResp, err error) {
return &ec2.InstancesResp{"",
[]ec2.Reservation{
ec2.Reservation{"", "", "", nil, instances}}}, nil
{"", "", "", nil, instances}}}, nil
}},
nil}
}
func TestList(t *testing.T) {
instances := make([]ec2.Instance, 4)
instances[0].Tags = []ec2.Tag{ec2.Tag{"Name", "foo"}}
instances[0].Tags = []ec2.Tag{{"Name", "foo"}}
instances[0].PrivateDNSName = "instance1"
instances[1].Tags = []ec2.Tag{ec2.Tag{"Name", "bar"}}
instances[1].Tags = []ec2.Tag{{"Name", "bar"}}
instances[1].PrivateDNSName = "instance2"
instances[2].Tags = []ec2.Tag{ec2.Tag{"Name", "baz"}}
instances[2].Tags = []ec2.Tag{{"Name", "baz"}}
instances[2].PrivateDNSName = "instance3"
instances[3].Tags = []ec2.Tag{ec2.Tag{"Name", "quux"}}
instances[3].Tags = []ec2.Tag{{"Name", "quux"}}
instances[3].PrivateDNSName = "instance4"
aws := mockInstancesResp(instances)

View File

@ -18,9 +18,9 @@ package ovirt_cloud
import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"fmt"
"net"
"net/http"
"net/url"
@ -32,8 +32,8 @@ import (
)
type OVirtCloud struct {
VmsRequest *url.URL
HostsRequest *url.URL
VmsRequest *url.URL
HostsRequest *url.URL
}
type OVirtApiConfig struct {
@ -43,18 +43,18 @@ type OVirtApiConfig struct {
Password string `gcfg:"password"`
}
Filters struct {
VmsQuery string `gcfg:"vms"`
VmsQuery string `gcfg:"vms"`
}
}
type XmlVmInfo struct {
Hostname string `xml:"guest_info>fqdn"`
State string `xml:"status>state"`
Hostname string `xml:"guest_info>fqdn"`
State string `xml:"status>state"`
}
type XmlVmsList struct {
XMLName xml.Name `xml:"vms"`
Vm []XmlVmInfo `xml:"vm"`
XMLName xml.Name `xml:"vms"`
Vm []XmlVmInfo `xml:"vm"`
}
func init() {
@ -74,7 +74,7 @@ func newOVirtCloud(config io.Reader) (*OVirtCloud, error) {
/* defaults */
oVirtConfig.Connection.Username = "admin@internal"
if err := gcfg.ReadInto(&oVirtConfig, config); err != nil {
if err := gcfg.ReadInto(&oVirtConfig, config); err != nil {
return nil, err
}
@ -83,7 +83,7 @@ func newOVirtCloud(config io.Reader) (*OVirtCloud, error) {
}
request, err := url.Parse(oVirtConfig.Connection.ApiEntry)
if err != nil {
if err != nil {
return nil, err
}
@ -121,7 +121,7 @@ func getInstancesFromXml(body io.Reader) ([]string, error) {
}
content, err := ioutil.ReadAll(body)
if err != nil {
if err != nil {
return nil, err
}
@ -146,7 +146,7 @@ func getInstancesFromXml(body io.Reader) ([]string, error) {
// List enumerates the set of minions instances known by the cloud provider
func (v *OVirtCloud) List(filter string) ([]string, error) {
response, err := http.Get(v.VmsRequest.String())
if err != nil {
if err != nil {
return nil, err
}

View File

@ -79,7 +79,7 @@ func TestExtractInvalidManifest(t *testing.T) {
desc: "Unspecified container name",
manifests: []api.ContainerManifest{
{
Version: "v1beta1",
Version: "v1beta1",
Containers: []api.Container{{Name: ""}},
},
},
@ -88,7 +88,7 @@ func TestExtractInvalidManifest(t *testing.T) {
desc: "Invalid container name",
manifests: []api.ContainerManifest{
{
Version: "v1beta1",
Version: "v1beta1",
Containers: []api.Container{{Name: "_INVALID_"}},
},
},

View File

@ -28,12 +28,12 @@ func TestDockerConfigJSONDecode(t *testing.T) {
input := []byte(`{"http://foo.example.com":{"username": "foo", "password": "bar", "email": "foo@example.com"}, "http://bar.example.com":{"username": "bar", "password": "baz", "email": "bar@example.com"}}`)
expect := dockerConfig(map[string]dockerConfigEntry{
"http://foo.example.com": dockerConfigEntry{
"http://foo.example.com": {
Username: "foo",
Password: "bar",
Email: "foo@example.com",
},
"http://bar.example.com": dockerConfigEntry{
"http://bar.example.com": {
Username: "bar",
Password: "baz",
Email: "bar@example.com",
@ -171,12 +171,12 @@ func TestDecodeDockerConfigFieldAuth(t *testing.T) {
func TestDockerKeyringFromConfig(t *testing.T) {
cfg := dockerConfig(map[string]dockerConfigEntry{
"http://foo.example.com": dockerConfigEntry{
"http://foo.example.com": {
Username: "foo",
Password: "bar",
Email: "foo@example.com",
},
"https://bar.example.com": dockerConfigEntry{
"https://bar.example.com": {
Username: "bar",
Password: "baz",
Email: "bar@example.com",

View File

@ -20,12 +20,12 @@ import (
"errors"
"fmt"
"hash/adler32"
"io"
"math/rand"
"os/exec"
"sort"
"strconv"
"strings"
"io"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/fsouza/go-dockerclient"

View File

@ -18,10 +18,10 @@ package kubelet
import (
"fmt"
"net"
"strconv"
"net/http"
"io"
"net"
"net/http"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@ -101,7 +101,7 @@ func (h *httpActionHandler) Run(podFullName, uuid string, container *api.Contain
// FlushWriter provides wrapper for responseWriter with HTTP streaming capabilities
type FlushWriter struct {
flusher http.Flusher
writer io.Writer
writer io.Writer
}
// Write is a FlushWriter implementation of the io.Writer that sends any buffered data to the client.

View File

@ -20,13 +20,13 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"path"
"strconv"
"strings"
"sync"
"time"
"io"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
@ -758,7 +758,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
if !found {
return fmt.Errorf("container not found (%s)\n", containerName)
}
return dockertools.GetKubeletDockerContainerLogs(kl.dockerClient, dockerContainer.ID, tail , follow, stdout, stderr)
return dockertools.GetKubeletDockerContainerLogs(kl.dockerClient, dockerContainer.ID, tail, follow, stdout, stderr)
}
// GetPodInfo returns information from Docker about the containers in a pod

View File

@ -172,7 +172,7 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
http.Error(w, `{"message": "Missing container name."}`, http.StatusBadRequest)
return
}
uriValues := u.Query()
follow, _ := strconv.ParseBool(uriValues.Get("follow"))
tail := uriValues.Get("tail")

View File

@ -20,6 +20,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
@ -27,7 +28,6 @@ import (
"reflect"
"strings"
"testing"
"io"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@ -36,13 +36,13 @@ import (
)
type fakeKubelet struct {
infoFunc func(name string) (api.PodInfo, error)
containerInfoFunc func(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
rootInfoFunc func(query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
machineInfoFunc func() (*info.MachineInfo, error)
logFunc func(w http.ResponseWriter, req *http.Request)
runFunc func(podFullName, uuid, containerName string, cmd []string) ([]byte, error)
containerLogsFunc func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
infoFunc func(name string) (api.PodInfo, error)
containerInfoFunc func(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
rootInfoFunc func(query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
machineInfoFunc func() (*info.MachineInfo, error)
logFunc func(w http.ResponseWriter, req *http.Request)
runFunc func(podFullName, uuid, containerName string, cmd []string) ([]byte, error)
containerLogsFunc func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
}
func (fk *fakeKubelet) GetPodInfo(name, uuid string) (api.PodInfo, error) {
@ -355,119 +355,119 @@ func TestServeRunInContainerWithUUID(t *testing.T) {
}
func TestContainerLogs(t *testing.T) {
fw := newServerTest()
output := "foo bar"
podName := "foo"
expectedPodName := podName + ".etcd"
expectedContainerName := "baz"
expectedTail := ""
expectedFollow := false
// expected := api.Container{"goodpod": docker.Container{ID: "myContainerID"}}
fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
if podFullName != expectedPodName {
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
}
if containerName != expectedContainerName {
t.Errorf("expected %s, got %s", expectedContainerName, containerName)
}
if tail != expectedTail {
t.Errorf("expected %s, got %s", expectedTail, tail)
}
if follow != expectedFollow {
t.Errorf("expected %t, got %t", expectedFollow, follow)
}
return nil
}
resp, err := http.Get(fw.testHTTPServer.URL+"/containerLogs/" + podName + "/" + expectedContainerName)
if err != nil {
t.Errorf("Got error GETing: %v", err)
}
defer resp.Body.Close()
fw := newServerTest()
output := "foo bar"
podName := "foo"
expectedPodName := podName + ".etcd"
expectedContainerName := "baz"
expectedTail := ""
expectedFollow := false
// expected := api.Container{"goodpod": docker.Container{ID: "myContainerID"}}
fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
if podFullName != expectedPodName {
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
}
if containerName != expectedContainerName {
t.Errorf("expected %s, got %s", expectedContainerName, containerName)
}
if tail != expectedTail {
t.Errorf("expected %s, got %s", expectedTail, tail)
}
if follow != expectedFollow {
t.Errorf("expected %t, got %t", expectedFollow, follow)
}
return nil
}
resp, err := http.Get(fw.testHTTPServer.URL + "/containerLogs/" + podName + "/" + expectedContainerName)
if err != nil {
t.Errorf("Got error GETing: %v", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("Error reading container logs: %v", err)
}
result := string(body)
if result != string(body) {
t.Errorf("Expected: '%v', got: '%v'", output, result)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("Error reading container logs: %v", err)
}
result := string(body)
if result != string(body) {
t.Errorf("Expected: '%v', got: '%v'", output, result)
}
}
func TestContainerLogsWithTail(t *testing.T) {
fw := newServerTest()
output := "foo bar"
podName := "foo"
expectedPodName := podName + ".etcd"
expectedContainerName := "baz"
expectedTail := "5"
expectedFollow := false
fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
if podFullName != expectedPodName {
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
}
if containerName != expectedContainerName {
t.Errorf("expected %s, got %s", expectedContainerName, containerName)
}
if tail != expectedTail {
t.Errorf("expected %s, got %s", expectedTail, tail)
}
if follow != expectedFollow {
t.Errorf("expected %t, got %t", expectedFollow, follow)
}
return nil
}
resp, err := http.Get(fw.testHTTPServer.URL+"/containerLogs/" + podName + "/" + expectedContainerName + "?tail=5")
if err != nil {
t.Errorf("Got error GETing: %v", err)
}
defer resp.Body.Close()
fw := newServerTest()
output := "foo bar"
podName := "foo"
expectedPodName := podName + ".etcd"
expectedContainerName := "baz"
expectedTail := "5"
expectedFollow := false
fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
if podFullName != expectedPodName {
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
}
if containerName != expectedContainerName {
t.Errorf("expected %s, got %s", expectedContainerName, containerName)
}
if tail != expectedTail {
t.Errorf("expected %s, got %s", expectedTail, tail)
}
if follow != expectedFollow {
t.Errorf("expected %t, got %t", expectedFollow, follow)
}
return nil
}
resp, err := http.Get(fw.testHTTPServer.URL + "/containerLogs/" + podName + "/" + expectedContainerName + "?tail=5")
if err != nil {
t.Errorf("Got error GETing: %v", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("Error reading container logs: %v", err)
}
result := string(body)
if result != string(body) {
t.Errorf("Expected: '%v', got: '%v'", output, result)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("Error reading container logs: %v", err)
}
result := string(body)
if result != string(body) {
t.Errorf("Expected: '%v', got: '%v'", output, result)
}
}
func TestContainerLogsWithFollow(t *testing.T) {
fw := newServerTest()
output := "foo bar"
podName := "foo"
expectedPodName := podName + ".etcd"
expectedContainerName := "baz"
expectedTail := ""
expectedFollow := true
fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
if podFullName != expectedPodName {
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
}
if containerName != expectedContainerName {
t.Errorf("expected %s, got %s", expectedContainerName, containerName)
}
if tail != expectedTail {
t.Errorf("expected %s, got %s", expectedTail, tail)
}
if follow != expectedFollow {
t.Errorf("expected %t, got %t", expectedFollow, follow)
}
return nil
}
resp, err := http.Get(fw.testHTTPServer.URL+"/containerLogs/" + podName + "/" + expectedContainerName + "?follow=1")
if err != nil {
t.Errorf("Got error GETing: %v", err)
}
defer resp.Body.Close()
fw := newServerTest()
output := "foo bar"
podName := "foo"
expectedPodName := podName + ".etcd"
expectedContainerName := "baz"
expectedTail := ""
expectedFollow := true
fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
if podFullName != expectedPodName {
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
}
if containerName != expectedContainerName {
t.Errorf("expected %s, got %s", expectedContainerName, containerName)
}
if tail != expectedTail {
t.Errorf("expected %s, got %s", expectedTail, tail)
}
if follow != expectedFollow {
t.Errorf("expected %t, got %t", expectedFollow, follow)
}
return nil
}
resp, err := http.Get(fw.testHTTPServer.URL + "/containerLogs/" + podName + "/" + expectedContainerName + "?follow=1")
if err != nil {
t.Errorf("Got error GETing: %v", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("Error reading container logs: %v", err)
}
result := string(body)
if result != string(body) {
t.Errorf("Expected: '%v', got: '%v'", output, result)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("Error reading container logs: %v", err)
}
result := string(body)
if result != string(body) {
t.Errorf("Expected: '%v', got: '%v'", output, result)
}
}