Use go-dockerclient's APIVersion

Use go-dockerclient's APIVersion to check the minimum required Docker
version, as it contains methods for parsing the ApiVersion response from
the Docker daemon and for comparing 2 APIVersion objects.
This commit is contained in:
Andy Goldstein
2015-04-20 13:48:18 -04:00
parent cf27de61c6
commit a0a80ea76e
6 changed files with 34 additions and 66 deletions

View File

@@ -35,6 +35,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/httpstream"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/httpstream/spdy"
"github.com/fsouza/go-dockerclient"
cadvisorApi "github.com/google/cadvisor/info/v1"
)
@@ -47,7 +48,7 @@ type fakeKubelet struct {
podsFunc func() []*api.Pod
logFunc func(w http.ResponseWriter, req *http.Request)
runFunc func(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error)
dockerVersionFunc func() ([]uint, error)
dockerVersionFunc func() (docker.APIVersion, error)
execFunc func(pod string, uid types.UID, container string, cmd []string, in io.Reader, out, err io.WriteCloser, tty bool) error
portForwardFunc func(name string, uid types.UID, port uint16, stream io.ReadWriteCloser) error
containerLogsFunc func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
@@ -71,7 +72,7 @@ func (fk *fakeKubelet) GetRootInfo(req *cadvisorApi.ContainerInfoRequest) (*cadv
return fk.rootInfoFunc(req)
}
func (fk *fakeKubelet) GetDockerVersion() ([]uint, error) {
func (fk *fakeKubelet) GetDockerVersion() (docker.APIVersion, error) {
return fk.dockerVersionFunc()
}
@@ -449,8 +450,8 @@ func TestPodsInfo(t *testing.T) {
func TestHealthCheck(t *testing.T) {
fw := newServerTest()
fw.fakeKubelet.dockerVersionFunc = func() ([]uint, error) {
return []uint{1, 15}, nil
fw.fakeKubelet.dockerVersionFunc = func() (docker.APIVersion, error) {
return docker.NewAPIVersion("1.15")
}
fw.fakeKubelet.hostnameFunc = func() string {
return "127.0.0.1"
@@ -489,8 +490,8 @@ func TestHealthCheck(t *testing.T) {
}
//Test with old docker version
fw.fakeKubelet.dockerVersionFunc = func() ([]uint, error) {
return []uint{1, 1}, nil
fw.fakeKubelet.dockerVersionFunc = func() (docker.APIVersion, error) {
return docker.NewAPIVersion("1.1")
}
resp, err = http.Get(fw.testHTTPServer.URL + "/healthz")