mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	@@ -4,7 +4,7 @@ go:
 | 
				
			|||||||
  - 1.3
 | 
					  - 1.3
 | 
				
			||||||
  - 1.2
 | 
					  - 1.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
install: 
 | 
					install:
 | 
				
			||||||
  - go get code.google.com/p/go.tools/cmd/cover
 | 
					  - go get code.google.com/p/go.tools/cmd/cover
 | 
				
			||||||
  - ./hack/install-etcd.sh
 | 
					  - ./hack/install-etcd.sh
 | 
				
			||||||
  - ./hack/verify-gofmt.sh
 | 
					  - ./hack/verify-gofmt.sh
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,6 @@ package main
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/aws"
 | 
						_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/aws"
 | 
				
			||||||
	_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/gce"
 | 
						_ "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/ovirt"
 | 
				
			||||||
 | 
						_ "github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider/vagrant"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,10 +17,9 @@
 | 
				
			|||||||
# GoFmt apparently is changing @ head...
 | 
					# GoFmt apparently is changing @ head...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GO_VERSION=($(go version))
 | 
					GO_VERSION=($(go version))
 | 
				
			||||||
echo "Detected go version: $(go version)"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ ${GO_VERSION[2]} != "go1.2" && ${GO_VERSION[2]} != "go1.3" ]]; then
 | 
					if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.2|go1.3') ]]; then
 | 
				
			||||||
  echo "Unknown go version, skipping gofmt."
 | 
					  echo "Unknown go version '${GO_VERSION}', skipping gofmt."
 | 
				
			||||||
  exit 0
 | 
					  exit 0
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,7 +85,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
 | 
				
			|||||||
func TestInternalRoundTrip(t *testing.T) {
 | 
					func TestInternalRoundTrip(t *testing.T) {
 | 
				
			||||||
	latest := "v1beta2"
 | 
						latest := "v1beta2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for k, _ := range internal.Scheme.KnownTypes("") {
 | 
						for k := range internal.Scheme.KnownTypes("") {
 | 
				
			||||||
		obj, err := internal.Scheme.New("", k)
 | 
							obj, err := internal.Scheme.New("", k)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			t.Errorf("%s: unexpected error: %v", k, err)
 | 
								t.Errorf("%s: unexpected error: %v", k, err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,20 +89,20 @@ func mockInstancesResp(instances []ec2.Instance) (aws *AWSCloud) {
 | 
				
			|||||||
			func(instanceIds []string, filter *ec2.Filter) (resp *ec2.InstancesResp, err error) {
 | 
								func(instanceIds []string, filter *ec2.Filter) (resp *ec2.InstancesResp, err error) {
 | 
				
			||||||
				return &ec2.InstancesResp{"",
 | 
									return &ec2.InstancesResp{"",
 | 
				
			||||||
					[]ec2.Reservation{
 | 
										[]ec2.Reservation{
 | 
				
			||||||
						ec2.Reservation{"", "", "", nil, instances}}}, nil
 | 
											{"", "", "", nil, instances}}}, nil
 | 
				
			||||||
			}},
 | 
								}},
 | 
				
			||||||
		nil}
 | 
							nil}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestList(t *testing.T) {
 | 
					func TestList(t *testing.T) {
 | 
				
			||||||
	instances := make([]ec2.Instance, 4)
 | 
						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[0].PrivateDNSName = "instance1"
 | 
				
			||||||
	instances[1].Tags = []ec2.Tag{ec2.Tag{"Name", "bar"}}
 | 
						instances[1].Tags = []ec2.Tag{{"Name", "bar"}}
 | 
				
			||||||
	instances[1].PrivateDNSName = "instance2"
 | 
						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[2].PrivateDNSName = "instance3"
 | 
				
			||||||
	instances[3].Tags = []ec2.Tag{ec2.Tag{"Name", "quux"}}
 | 
						instances[3].Tags = []ec2.Tag{{"Name", "quux"}}
 | 
				
			||||||
	instances[3].PrivateDNSName = "instance4"
 | 
						instances[3].PrivateDNSName = "instance4"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	aws := mockInstancesResp(instances)
 | 
						aws := mockInstancesResp(instances)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,9 +18,9 @@ package ovirt_cloud
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/xml"
 | 
						"encoding/xml"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"net"
 | 
						"net"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"net/url"
 | 
						"net/url"
 | 
				
			||||||
@@ -32,8 +32,8 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type OVirtCloud struct {
 | 
					type OVirtCloud struct {
 | 
				
			||||||
	VmsRequest         *url.URL
 | 
						VmsRequest   *url.URL
 | 
				
			||||||
	HostsRequest       *url.URL
 | 
						HostsRequest *url.URL
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type OVirtApiConfig struct {
 | 
					type OVirtApiConfig struct {
 | 
				
			||||||
@@ -43,18 +43,18 @@ type OVirtApiConfig struct {
 | 
				
			|||||||
		Password string `gcfg:"password"`
 | 
							Password string `gcfg:"password"`
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	Filters struct {
 | 
						Filters struct {
 | 
				
			||||||
		VmsQuery   string `gcfg:"vms"`
 | 
							VmsQuery string `gcfg:"vms"`
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XmlVmInfo struct {
 | 
					type XmlVmInfo struct {
 | 
				
			||||||
	Hostname        string `xml:"guest_info>fqdn"`
 | 
						Hostname string `xml:"guest_info>fqdn"`
 | 
				
			||||||
	State		string `xml:"status>state"`
 | 
						State    string `xml:"status>state"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XmlVmsList struct {
 | 
					type XmlVmsList struct {
 | 
				
			||||||
	XMLName         xml.Name     `xml:"vms"`
 | 
						XMLName xml.Name    `xml:"vms"`
 | 
				
			||||||
	Vm		[]XmlVmInfo  `xml:"vm"`
 | 
						Vm      []XmlVmInfo `xml:"vm"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
@@ -74,7 +74,7 @@ func newOVirtCloud(config io.Reader) (*OVirtCloud, error) {
 | 
				
			|||||||
	/* defaults */
 | 
						/* defaults */
 | 
				
			||||||
	oVirtConfig.Connection.Username = "admin@internal"
 | 
						oVirtConfig.Connection.Username = "admin@internal"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if  err := gcfg.ReadInto(&oVirtConfig, config); err != nil {
 | 
						if err := gcfg.ReadInto(&oVirtConfig, config); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -83,7 +83,7 @@ func newOVirtCloud(config io.Reader) (*OVirtCloud, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	request, err := url.Parse(oVirtConfig.Connection.ApiEntry)
 | 
						request, err := url.Parse(oVirtConfig.Connection.ApiEntry)
 | 
				
			||||||
	if  err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -121,7 +121,7 @@ func getInstancesFromXml(body io.Reader) ([]string, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	content, err := ioutil.ReadAll(body)
 | 
						content, err := ioutil.ReadAll(body)
 | 
				
			||||||
	if  err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							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
 | 
					// List enumerates the set of minions instances known by the cloud provider
 | 
				
			||||||
func (v *OVirtCloud) List(filter string) ([]string, error) {
 | 
					func (v *OVirtCloud) List(filter string) ([]string, error) {
 | 
				
			||||||
	response, err := http.Get(v.VmsRequest.String())
 | 
						response, err := http.Get(v.VmsRequest.String())
 | 
				
			||||||
	if  err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ func TestExtractInvalidManifest(t *testing.T) {
 | 
				
			|||||||
			desc: "Unspecified container name",
 | 
								desc: "Unspecified container name",
 | 
				
			||||||
			manifests: []api.ContainerManifest{
 | 
								manifests: []api.ContainerManifest{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					Version: "v1beta1",
 | 
										Version:    "v1beta1",
 | 
				
			||||||
					Containers: []api.Container{{Name: ""}},
 | 
										Containers: []api.Container{{Name: ""}},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -88,7 +88,7 @@ func TestExtractInvalidManifest(t *testing.T) {
 | 
				
			|||||||
			desc: "Invalid container name",
 | 
								desc: "Invalid container name",
 | 
				
			||||||
			manifests: []api.ContainerManifest{
 | 
								manifests: []api.ContainerManifest{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					Version: "v1beta1",
 | 
										Version:    "v1beta1",
 | 
				
			||||||
					Containers: []api.Container{{Name: "_INVALID_"}},
 | 
										Containers: []api.Container{{Name: "_INVALID_"}},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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"}}`)
 | 
						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{
 | 
						expect := dockerConfig(map[string]dockerConfigEntry{
 | 
				
			||||||
		"http://foo.example.com": dockerConfigEntry{
 | 
							"http://foo.example.com": {
 | 
				
			||||||
			Username: "foo",
 | 
								Username: "foo",
 | 
				
			||||||
			Password: "bar",
 | 
								Password: "bar",
 | 
				
			||||||
			Email:    "foo@example.com",
 | 
								Email:    "foo@example.com",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"http://bar.example.com": dockerConfigEntry{
 | 
							"http://bar.example.com": {
 | 
				
			||||||
			Username: "bar",
 | 
								Username: "bar",
 | 
				
			||||||
			Password: "baz",
 | 
								Password: "baz",
 | 
				
			||||||
			Email:    "bar@example.com",
 | 
								Email:    "bar@example.com",
 | 
				
			||||||
@@ -171,12 +171,12 @@ func TestDecodeDockerConfigFieldAuth(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestDockerKeyringFromConfig(t *testing.T) {
 | 
					func TestDockerKeyringFromConfig(t *testing.T) {
 | 
				
			||||||
	cfg := dockerConfig(map[string]dockerConfigEntry{
 | 
						cfg := dockerConfig(map[string]dockerConfigEntry{
 | 
				
			||||||
		"http://foo.example.com": dockerConfigEntry{
 | 
							"http://foo.example.com": {
 | 
				
			||||||
			Username: "foo",
 | 
								Username: "foo",
 | 
				
			||||||
			Password: "bar",
 | 
								Password: "bar",
 | 
				
			||||||
			Email:    "foo@example.com",
 | 
								Email:    "foo@example.com",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"https://bar.example.com": dockerConfigEntry{
 | 
							"https://bar.example.com": {
 | 
				
			||||||
			Username: "bar",
 | 
								Username: "bar",
 | 
				
			||||||
			Password: "baz",
 | 
								Password: "baz",
 | 
				
			||||||
			Email:    "bar@example.com",
 | 
								Email:    "bar@example.com",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,12 +20,12 @@ import (
 | 
				
			|||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"hash/adler32"
 | 
						"hash/adler32"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
	"os/exec"
 | 
						"os/exec"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
				
			||||||
	"github.com/fsouza/go-dockerclient"
 | 
						"github.com/fsouza/go-dockerclient"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,10 +18,10 @@ package kubelet
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"net"
 | 
					 | 
				
			||||||
	"strconv"
 | 
					 | 
				
			||||||
	"net/http"
 | 
					 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
 | 
						"net"
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
 | 
						"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
 | 
					// FlushWriter provides wrapper for responseWriter with HTTP streaming capabilities
 | 
				
			||||||
type FlushWriter struct {
 | 
					type FlushWriter struct {
 | 
				
			||||||
	flusher http.Flusher
 | 
						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.
 | 
					// Write is a FlushWriter implementation of the io.Writer that sends any buffered data to the client.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,13 +20,13 @@ import (
 | 
				
			|||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"path"
 | 
						"path"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
 | 
				
			||||||
@@ -758,7 +758,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
 | 
				
			|||||||
	if !found {
 | 
						if !found {
 | 
				
			||||||
		return fmt.Errorf("container not found (%s)\n", containerName)
 | 
							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
 | 
					// GetPodInfo returns information from Docker about the containers in a pod
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -172,7 +172,7 @@ func (s *Server) handleContainerLogs(w http.ResponseWriter, req *http.Request) {
 | 
				
			|||||||
		http.Error(w, `{"message": "Missing container name."}`, http.StatusBadRequest)
 | 
							http.Error(w, `{"message": "Missing container name."}`, http.StatusBadRequest)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	uriValues := u.Query()
 | 
						uriValues := u.Query()
 | 
				
			||||||
	follow, _ := strconv.ParseBool(uriValues.Get("follow"))
 | 
						follow, _ := strconv.ParseBool(uriValues.Get("follow"))
 | 
				
			||||||
	tail := uriValues.Get("tail")
 | 
						tail := uriValues.Get("tail")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@ import (
 | 
				
			|||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"net/http/httptest"
 | 
						"net/http/httptest"
 | 
				
			||||||
@@ -27,7 +28,6 @@ import (
 | 
				
			|||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"io"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
 | 
				
			||||||
	"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
 | 
						"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
 | 
				
			||||||
@@ -36,13 +36,13 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type fakeKubelet struct {
 | 
					type fakeKubelet struct {
 | 
				
			||||||
	infoFunc           func(name string) (api.PodInfo, error)
 | 
						infoFunc          func(name string) (api.PodInfo, error)
 | 
				
			||||||
	containerInfoFunc  func(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
 | 
						containerInfoFunc func(podFullName, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
 | 
				
			||||||
	rootInfoFunc       func(query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
 | 
						rootInfoFunc      func(query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
 | 
				
			||||||
	machineInfoFunc    func() (*info.MachineInfo, error)
 | 
						machineInfoFunc   func() (*info.MachineInfo, error)
 | 
				
			||||||
	logFunc            func(w http.ResponseWriter, req *http.Request)
 | 
						logFunc           func(w http.ResponseWriter, req *http.Request)
 | 
				
			||||||
	runFunc            func(podFullName, uuid, containerName string, cmd []string) ([]byte, error)
 | 
						runFunc           func(podFullName, uuid, containerName string, cmd []string) ([]byte, error)
 | 
				
			||||||
	containerLogsFunc  func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer)  error
 | 
						containerLogsFunc func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (fk *fakeKubelet) GetPodInfo(name, uuid string) (api.PodInfo, 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) {
 | 
					func TestContainerLogs(t *testing.T) {
 | 
				
			||||||
    fw := newServerTest()
 | 
						fw := newServerTest()
 | 
				
			||||||
    output := "foo bar"
 | 
						output := "foo bar"
 | 
				
			||||||
    podName := "foo"
 | 
						podName := "foo"
 | 
				
			||||||
    expectedPodName := podName + ".etcd"
 | 
						expectedPodName := podName + ".etcd"
 | 
				
			||||||
    expectedContainerName := "baz"
 | 
						expectedContainerName := "baz"
 | 
				
			||||||
    expectedTail := ""
 | 
						expectedTail := ""
 | 
				
			||||||
    expectedFollow := false
 | 
						expectedFollow := false
 | 
				
			||||||
    // expected := api.Container{"goodpod": docker.Container{ID: "myContainerID"}}
 | 
						// expected := api.Container{"goodpod": docker.Container{ID: "myContainerID"}}
 | 
				
			||||||
    fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
 | 
						fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
 | 
				
			||||||
            if podFullName != expectedPodName {
 | 
							if podFullName != expectedPodName {
 | 
				
			||||||
                    t.Errorf("expected %s, got %s", expectedPodName, podFullName)
 | 
								t.Errorf("expected %s, got %s", expectedPodName, podFullName)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
			if containerName != expectedContainerName {
 | 
							if containerName != expectedContainerName {
 | 
				
			||||||
				t.Errorf("expected %s, got %s", expectedContainerName, containerName)
 | 
								t.Errorf("expected %s, got %s", expectedContainerName, containerName)
 | 
				
			||||||
			}
 | 
							}
 | 
				
			||||||
            if tail != expectedTail {
 | 
							if tail != expectedTail {
 | 
				
			||||||
                    t.Errorf("expected %s, got %s", expectedTail, tail)
 | 
								t.Errorf("expected %s, got %s", expectedTail, tail)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
            if follow != expectedFollow {
 | 
							if follow != expectedFollow {
 | 
				
			||||||
                    t.Errorf("expected %t, got %t", expectedFollow, follow)
 | 
								t.Errorf("expected %t, got %t", expectedFollow, follow)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
            return nil
 | 
							return nil
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    resp, err := http.Get(fw.testHTTPServer.URL+"/containerLogs/" + podName + "/" + expectedContainerName)
 | 
						resp, err := http.Get(fw.testHTTPServer.URL + "/containerLogs/" + podName + "/" + expectedContainerName)
 | 
				
			||||||
    if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
            t.Errorf("Got error GETing: %v", err)
 | 
							t.Errorf("Got error GETing: %v", err)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    defer resp.Body.Close()
 | 
						defer resp.Body.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    body, err := ioutil.ReadAll(resp.Body)
 | 
						body, err := ioutil.ReadAll(resp.Body)
 | 
				
			||||||
    if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
            t.Errorf("Error reading container logs: %v", err)
 | 
							t.Errorf("Error reading container logs: %v", err)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    result := string(body)
 | 
						result := string(body)
 | 
				
			||||||
    if result != string(body) {
 | 
						if result != string(body) {
 | 
				
			||||||
            t.Errorf("Expected: '%v', got: '%v'", output, result)
 | 
							t.Errorf("Expected: '%v', got: '%v'", output, result)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestContainerLogsWithTail(t *testing.T) {
 | 
					func TestContainerLogsWithTail(t *testing.T) {
 | 
				
			||||||
    fw := newServerTest()
 | 
						fw := newServerTest()
 | 
				
			||||||
    output := "foo bar"
 | 
						output := "foo bar"
 | 
				
			||||||
    podName := "foo"
 | 
						podName := "foo"
 | 
				
			||||||
    expectedPodName := podName + ".etcd"
 | 
						expectedPodName := podName + ".etcd"
 | 
				
			||||||
    expectedContainerName := "baz"
 | 
						expectedContainerName := "baz"
 | 
				
			||||||
    expectedTail := "5"
 | 
						expectedTail := "5"
 | 
				
			||||||
    expectedFollow := false
 | 
						expectedFollow := false
 | 
				
			||||||
    fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
 | 
						fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
 | 
				
			||||||
            if podFullName != expectedPodName {
 | 
							if podFullName != expectedPodName {
 | 
				
			||||||
                    t.Errorf("expected %s, got %s", expectedPodName, podFullName)
 | 
								t.Errorf("expected %s, got %s", expectedPodName, podFullName)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
			if containerName != expectedContainerName {
 | 
							if containerName != expectedContainerName {
 | 
				
			||||||
				t.Errorf("expected %s, got %s", expectedContainerName, containerName)
 | 
								t.Errorf("expected %s, got %s", expectedContainerName, containerName)
 | 
				
			||||||
			}
 | 
							}
 | 
				
			||||||
            if tail != expectedTail {
 | 
							if tail != expectedTail {
 | 
				
			||||||
                    t.Errorf("expected %s, got %s", expectedTail, tail)
 | 
								t.Errorf("expected %s, got %s", expectedTail, tail)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
            if follow != expectedFollow {
 | 
							if follow != expectedFollow {
 | 
				
			||||||
                    t.Errorf("expected %t, got %t", expectedFollow, follow)
 | 
								t.Errorf("expected %t, got %t", expectedFollow, follow)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
            return nil
 | 
							return nil
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    resp, err := http.Get(fw.testHTTPServer.URL+"/containerLogs/" + podName + "/" + expectedContainerName + "?tail=5")
 | 
						resp, err := http.Get(fw.testHTTPServer.URL + "/containerLogs/" + podName + "/" + expectedContainerName + "?tail=5")
 | 
				
			||||||
    if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
            t.Errorf("Got error GETing: %v", err)
 | 
							t.Errorf("Got error GETing: %v", err)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    defer resp.Body.Close()
 | 
						defer resp.Body.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    body, err := ioutil.ReadAll(resp.Body)
 | 
						body, err := ioutil.ReadAll(resp.Body)
 | 
				
			||||||
    if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
            t.Errorf("Error reading container logs: %v", err)
 | 
							t.Errorf("Error reading container logs: %v", err)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    result := string(body)
 | 
						result := string(body)
 | 
				
			||||||
    if result != string(body) {
 | 
						if result != string(body) {
 | 
				
			||||||
            t.Errorf("Expected: '%v', got: '%v'", output, result)
 | 
							t.Errorf("Expected: '%v', got: '%v'", output, result)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestContainerLogsWithFollow(t *testing.T) {
 | 
					func TestContainerLogsWithFollow(t *testing.T) {
 | 
				
			||||||
    fw := newServerTest()
 | 
						fw := newServerTest()
 | 
				
			||||||
    output := "foo bar"
 | 
						output := "foo bar"
 | 
				
			||||||
    podName := "foo"
 | 
						podName := "foo"
 | 
				
			||||||
    expectedPodName := podName + ".etcd"
 | 
						expectedPodName := podName + ".etcd"
 | 
				
			||||||
    expectedContainerName := "baz"
 | 
						expectedContainerName := "baz"
 | 
				
			||||||
    expectedTail := ""
 | 
						expectedTail := ""
 | 
				
			||||||
    expectedFollow := true
 | 
						expectedFollow := true
 | 
				
			||||||
    fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
 | 
						fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
 | 
				
			||||||
            if podFullName != expectedPodName {
 | 
							if podFullName != expectedPodName {
 | 
				
			||||||
                    t.Errorf("expected %s, got %s", expectedPodName, podFullName)
 | 
								t.Errorf("expected %s, got %s", expectedPodName, podFullName)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
			if containerName != expectedContainerName {
 | 
							if containerName != expectedContainerName {
 | 
				
			||||||
				t.Errorf("expected %s, got %s", expectedContainerName, containerName)
 | 
								t.Errorf("expected %s, got %s", expectedContainerName, containerName)
 | 
				
			||||||
			}
 | 
							}
 | 
				
			||||||
            if tail != expectedTail {
 | 
							if tail != expectedTail {
 | 
				
			||||||
                    t.Errorf("expected %s, got %s", expectedTail, tail)
 | 
								t.Errorf("expected %s, got %s", expectedTail, tail)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
            if follow != expectedFollow {
 | 
							if follow != expectedFollow {
 | 
				
			||||||
                    t.Errorf("expected %t, got %t", expectedFollow, follow)
 | 
								t.Errorf("expected %t, got %t", expectedFollow, follow)
 | 
				
			||||||
            }
 | 
							}
 | 
				
			||||||
            return nil
 | 
							return nil
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    resp, err := http.Get(fw.testHTTPServer.URL+"/containerLogs/" + podName + "/" + expectedContainerName + "?follow=1")
 | 
						resp, err := http.Get(fw.testHTTPServer.URL + "/containerLogs/" + podName + "/" + expectedContainerName + "?follow=1")
 | 
				
			||||||
    if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
            t.Errorf("Got error GETing: %v", err)
 | 
							t.Errorf("Got error GETing: %v", err)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    defer resp.Body.Close()
 | 
						defer resp.Body.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    body, err := ioutil.ReadAll(resp.Body)
 | 
						body, err := ioutil.ReadAll(resp.Body)
 | 
				
			||||||
    if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
            t.Errorf("Error reading container logs: %v", err)
 | 
							t.Errorf("Error reading container logs: %v", err)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
    result := string(body)
 | 
						result := string(body)
 | 
				
			||||||
    if result != string(body) {
 | 
						if result != string(body) {
 | 
				
			||||||
            t.Errorf("Expected: '%v', got: '%v'", output, result)
 | 
							t.Errorf("Expected: '%v', got: '%v'", output, result)
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user