Allow server and client to take api version as argument

* Defaults to v1beta1
* apiserver takes -storage_version which controls etcd storage version
  and the version of the client used to connect to other apiservers
* Changed signature of client.New to add version parameter
* All controller code and component code prefers the oldest (most common)
  server version
This commit is contained in:
Clayton Coleman
2014-09-11 19:01:29 -04:00
parent ca5355908f
commit 5483333e29
22 changed files with 309 additions and 164 deletions

View File

@@ -22,6 +22,7 @@ import (
"net/http"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
masterPkg "github.com/GoogleCloudPlatform/kubernetes/pkg/master"
@@ -46,7 +47,7 @@ func main() {
verflag.PrintAndExitIfRequested()
// TODO: security story for plugins!
kubeClient, err := client.New(*master, nil)
kubeClient, err := client.New(*master, latest.OldestVersion, nil)
if err != nil {
glog.Fatalf("Invalid -master: %v", err)
}

View File

@@ -39,7 +39,7 @@ func TestCreate(t *testing.T) {
T: t,
}
server := httptest.NewServer(&handler)
client := client.NewOrDie(server.URL, nil)
client := client.NewOrDie(server.URL, "", nil)
factory := ConfigFactory{client}
factory.Create()
}
@@ -74,7 +74,7 @@ func TestCreateLists(t *testing.T) {
T: t,
}
server := httptest.NewServer(&handler)
factory.Client = client.NewOrDie(server.URL, nil)
factory.Client = client.NewOrDie(server.URL, latest.OldestVersion, nil)
// This test merely tests that the correct request is made.
item.factory().List()
handler.ValidateRequest(t, item.location, "GET", nil)
@@ -127,7 +127,7 @@ func TestCreateWatches(t *testing.T) {
T: t,
}
server := httptest.NewServer(&handler)
factory.Client = client.NewOrDie(server.URL, nil)
factory.Client = client.NewOrDie(server.URL, "v1beta1", nil)
// This test merely tests that the correct request is made.
item.factory().Watch(item.rv)
handler.ValidateRequest(t, item.location, "GET", nil)
@@ -157,7 +157,7 @@ func TestPollMinions(t *testing.T) {
// FakeHandler musn't be sent requests other than the one you want to test.
mux.Handle("/api/v1beta1/minions", &handler)
server := httptest.NewServer(mux)
client := client.NewOrDie(server.URL, nil)
client := client.NewOrDie(server.URL, "v1beta1", nil)
cf := ConfigFactory{client}
ce, err := cf.pollMinions()
@@ -184,7 +184,7 @@ func TestDefaultErrorFunc(t *testing.T) {
// FakeHandler musn't be sent requests other than the one you want to test.
mux.Handle("/api/v1beta1/pods/foo", &handler)
server := httptest.NewServer(mux)
factory := ConfigFactory{client.NewOrDie(server.URL, nil)}
factory := ConfigFactory{client.NewOrDie(server.URL, "", nil)}
queue := cache.NewFIFO()
errFunc := factory.makeDefaultErrorFunc(queue)
@@ -289,7 +289,7 @@ func TestBind(t *testing.T) {
T: t,
}
server := httptest.NewServer(&handler)
client := client.NewOrDie(server.URL, nil)
client := client.NewOrDie(server.URL, "", nil)
b := binder{client}
if err := b.Bind(item.binding); err != nil {