mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 07:03:31 +00:00
Removing more references to v1beta1 from pkg/
This commit is contained in:
@@ -36,8 +36,6 @@ import (
|
||||
apierrors "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
@@ -712,7 +710,7 @@ func TestDoRequestNewWay(t *testing.T) {
|
||||
Port: 12345,
|
||||
TargetPort: util.NewIntOrStringFromInt(12345),
|
||||
}}}}
|
||||
expectedBody, _ := v1beta2.Codec.Encode(expectedObj)
|
||||
expectedBody, _ := testapi.Codec().Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
@@ -720,7 +718,7 @@ func TestDoRequestNewWay(t *testing.T) {
|
||||
}
|
||||
testServer := httptest.NewServer(&fakeHandler)
|
||||
defer testServer.Close()
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta2", Username: "user", Password: "pass"})
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: testapi.Version(), Username: "user", Password: "pass"})
|
||||
obj, err := c.Verb("POST").
|
||||
Prefix("foo", "bar").
|
||||
Suffix("baz").
|
||||
@@ -736,7 +734,9 @@ func TestDoRequestNewWay(t *testing.T) {
|
||||
} else if !api.Semantic.DeepDerivative(expectedObj, obj) {
|
||||
t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
|
||||
}
|
||||
fakeHandler.ValidateRequest(t, "/api/v1beta2/foo/bar/baz?timeout=1s", "POST", &reqBody)
|
||||
requestURL := testapi.ResourcePathWithPrefix("foo/bar", "", "", "baz")
|
||||
requestURL += "?timeout=1s"
|
||||
fakeHandler.ValidateRequest(t, requestURL, "POST", &reqBody)
|
||||
if fakeHandler.RequestReceived.Header["Authorization"] == nil {
|
||||
t.Errorf("Request is missing authorization header: %#v", *fakeHandler.RequestReceived)
|
||||
}
|
||||
@@ -758,7 +758,7 @@ func TestCheckRetryClosesBody(t *testing.T) {
|
||||
}))
|
||||
defer testServer.Close()
|
||||
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta2", Username: "user", Password: "pass"})
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: testapi.Version(), Username: "user", Password: "pass"})
|
||||
_, err := c.Verb("POST").
|
||||
Prefix("foo", "bar").
|
||||
Suffix("baz").
|
||||
@@ -787,7 +787,7 @@ func BenchmarkCheckRetryClosesBody(t *testing.B) {
|
||||
}))
|
||||
defer testServer.Close()
|
||||
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta2", Username: "user", Password: "pass"})
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: testapi.Version(), Username: "user", Password: "pass"})
|
||||
r := c.Verb("POST").
|
||||
Prefix("foo", "bar").
|
||||
Suffix("baz").
|
||||
@@ -802,20 +802,20 @@ func BenchmarkCheckRetryClosesBody(t *testing.B) {
|
||||
}
|
||||
func TestDoRequestNewWayReader(t *testing.T) {
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, _ := v1beta1.Codec.Encode(reqObj)
|
||||
reqBodyExpected, _ := testapi.Codec().Encode(reqObj)
|
||||
expectedObj := &api.Service{Spec: api.ServiceSpec{Ports: []api.ServicePort{{
|
||||
Protocol: "TCP",
|
||||
Port: 12345,
|
||||
TargetPort: util.NewIntOrStringFromInt(12345),
|
||||
}}}}
|
||||
expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
|
||||
expectedBody, _ := testapi.Codec().Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
T: t,
|
||||
}
|
||||
testServer := httptest.NewServer(&fakeHandler)
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta1", Username: "user", Password: "pass"})
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: testapi.Version(), Username: "user", Password: "pass"})
|
||||
obj, err := c.Verb("POST").
|
||||
Resource("bar").
|
||||
Name("baz").
|
||||
@@ -834,7 +834,9 @@ func TestDoRequestNewWayReader(t *testing.T) {
|
||||
t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
|
||||
}
|
||||
tmpStr := string(reqBodyExpected)
|
||||
fakeHandler.ValidateRequest(t, "/api/v1beta1/foo/bar/baz?labels=name%3Dfoo&timeout=1s", "POST", &tmpStr)
|
||||
requestURL := testapi.ResourcePathWithPrefix("foo", "bar", "", "baz")
|
||||
requestURL += "?" + api.LabelSelectorQueryParam(testapi.Version()) + "=name%3Dfoo&timeout=1s"
|
||||
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
|
||||
if fakeHandler.RequestReceived.Header["Authorization"] == nil {
|
||||
t.Errorf("Request is missing authorization header: %#v", *fakeHandler.RequestReceived)
|
||||
}
|
||||
@@ -842,20 +844,20 @@ func TestDoRequestNewWayReader(t *testing.T) {
|
||||
|
||||
func TestDoRequestNewWayObj(t *testing.T) {
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, _ := v1beta2.Codec.Encode(reqObj)
|
||||
reqBodyExpected, _ := testapi.Codec().Encode(reqObj)
|
||||
expectedObj := &api.Service{Spec: api.ServiceSpec{Ports: []api.ServicePort{{
|
||||
Protocol: "TCP",
|
||||
Port: 12345,
|
||||
TargetPort: util.NewIntOrStringFromInt(12345),
|
||||
}}}}
|
||||
expectedBody, _ := v1beta2.Codec.Encode(expectedObj)
|
||||
expectedBody, _ := testapi.Codec().Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
T: t,
|
||||
}
|
||||
testServer := httptest.NewServer(&fakeHandler)
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta2", Username: "user", Password: "pass"})
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: testapi.Version(), Username: "user", Password: "pass"})
|
||||
obj, err := c.Verb("POST").
|
||||
Suffix("baz").
|
||||
Name("bar").
|
||||
@@ -874,7 +876,9 @@ func TestDoRequestNewWayObj(t *testing.T) {
|
||||
t.Errorf("Expected: %#v, got %#v", expectedObj, obj)
|
||||
}
|
||||
tmpStr := string(reqBodyExpected)
|
||||
fakeHandler.ValidateRequest(t, "/api/v1beta2/foo/bar/baz?labels=name%3Dfoo&timeout=1s", "POST", &tmpStr)
|
||||
requestURL := testapi.ResourcePath("foo", "", "bar/baz")
|
||||
requestURL += "?" + api.LabelSelectorQueryParam(testapi.Version()) + "=name%3Dfoo&timeout=1s"
|
||||
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
|
||||
if fakeHandler.RequestReceived.Header["Authorization"] == nil {
|
||||
t.Errorf("Request is missing authorization header: %#v", *fakeHandler.RequestReceived)
|
||||
}
|
||||
@@ -882,7 +886,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
|
||||
|
||||
func TestDoRequestNewWayFile(t *testing.T) {
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, err := v1beta1.Codec.Encode(reqObj)
|
||||
reqBodyExpected, err := testapi.Codec().Encode(reqObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -902,14 +906,14 @@ func TestDoRequestNewWayFile(t *testing.T) {
|
||||
Port: 12345,
|
||||
TargetPort: util.NewIntOrStringFromInt(12345),
|
||||
}}}}
|
||||
expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
|
||||
expectedBody, _ := testapi.Codec().Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 200,
|
||||
ResponseBody: string(expectedBody),
|
||||
T: t,
|
||||
}
|
||||
testServer := httptest.NewServer(&fakeHandler)
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta1", Username: "user", Password: "pass"})
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: testapi.Version(), Username: "user", Password: "pass"})
|
||||
wasCreated := true
|
||||
obj, err := c.Verb("POST").
|
||||
Prefix("foo/bar", "baz").
|
||||
@@ -929,7 +933,9 @@ func TestDoRequestNewWayFile(t *testing.T) {
|
||||
t.Errorf("expected object was not created")
|
||||
}
|
||||
tmpStr := string(reqBodyExpected)
|
||||
fakeHandler.ValidateRequest(t, "/api/v1beta1/foo/bar/baz?timeout=1s", "POST", &tmpStr)
|
||||
requestURL := testapi.ResourcePathWithPrefix("foo/bar/baz", "", "", "")
|
||||
requestURL += "?timeout=1s"
|
||||
fakeHandler.ValidateRequest(t, requestURL, "POST", &tmpStr)
|
||||
if fakeHandler.RequestReceived.Header["Authorization"] == nil {
|
||||
t.Errorf("Request is missing authorization header: %#v", *fakeHandler.RequestReceived)
|
||||
}
|
||||
@@ -937,7 +943,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
|
||||
|
||||
func TestWasCreated(t *testing.T) {
|
||||
reqObj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
reqBodyExpected, err := v1beta1.Codec.Encode(reqObj)
|
||||
reqBodyExpected, err := testapi.Codec().Encode(reqObj)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -947,14 +953,14 @@ func TestWasCreated(t *testing.T) {
|
||||
Port: 12345,
|
||||
TargetPort: util.NewIntOrStringFromInt(12345),
|
||||
}}}}
|
||||
expectedBody, _ := v1beta1.Codec.Encode(expectedObj)
|
||||
expectedBody, _ := testapi.Codec().Encode(expectedObj)
|
||||
fakeHandler := util.FakeHandler{
|
||||
StatusCode: 201,
|
||||
ResponseBody: string(expectedBody),
|
||||
T: t,
|
||||
}
|
||||
testServer := httptest.NewServer(&fakeHandler)
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: "v1beta1", Username: "user", Password: "pass"})
|
||||
c := NewOrDie(&Config{Host: testServer.URL, Version: testapi.Version(), Username: "user", Password: "pass"})
|
||||
wasCreated := false
|
||||
obj, err := c.Verb("PUT").
|
||||
Prefix("foo/bar", "baz").
|
||||
@@ -975,7 +981,9 @@ func TestWasCreated(t *testing.T) {
|
||||
}
|
||||
|
||||
tmpStr := string(reqBodyExpected)
|
||||
fakeHandler.ValidateRequest(t, "/api/v1beta1/foo/bar/baz?timeout=1s", "PUT", &tmpStr)
|
||||
requestURL := testapi.ResourcePathWithPrefix("foo/bar/baz", "", "", "")
|
||||
requestURL += "?timeout=1s"
|
||||
fakeHandler.ValidateRequest(t, requestURL, "PUT", &tmpStr)
|
||||
if fakeHandler.RequestReceived.Header["Authorization"] == nil {
|
||||
t.Errorf("Request is missing authorization header: %#v", *fakeHandler.RequestReceived)
|
||||
}
|
||||
@@ -1142,7 +1150,7 @@ func TestWatch(t *testing.T) {
|
||||
|
||||
s, err := New(&Config{
|
||||
Host: testServer.URL,
|
||||
Version: "v1beta1",
|
||||
Version: testapi.Version(),
|
||||
Username: "user",
|
||||
Password: "pass",
|
||||
})
|
||||
@@ -1192,7 +1200,7 @@ func TestStream(t *testing.T) {
|
||||
|
||||
s, err := New(&Config{
|
||||
Host: testServer.URL,
|
||||
Version: "v1beta1",
|
||||
Version: testapi.Version(),
|
||||
Username: "user",
|
||||
Password: "pass",
|
||||
})
|
||||
|
@@ -25,9 +25,6 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta2"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
)
|
||||
@@ -38,11 +35,8 @@ func TestSetsCodec(t *testing.T) {
|
||||
Prefix string
|
||||
Codec runtime.Codec
|
||||
}{
|
||||
"v1beta1": {false, "/api/v1beta1/", v1beta1.Codec},
|
||||
"": {false, "/api/" + latest.Version + "/", latest.Codec},
|
||||
"v1beta2": {false, "/api/v1beta2/", v1beta2.Codec},
|
||||
"v1beta3": {false, "/api/v1beta3/", v1beta3.Codec},
|
||||
"v1beta4": {true, "", nil},
|
||||
testapi.Version(): {false, "/api/" + testapi.Version() + "/", testapi.Codec()},
|
||||
"invalidVersion": {true, "", nil},
|
||||
}
|
||||
for version, expected := range testCases {
|
||||
client, err := New(&Config{Host: "127.0.0.1", Version: version})
|
||||
@@ -69,7 +63,7 @@ func TestRESTClientRequires(t *testing.T) {
|
||||
if _, err := RESTClientFor(&Config{Host: "127.0.0.1", Version: "", Codec: testapi.Codec()}); err == nil {
|
||||
t.Errorf("unexpected non-error")
|
||||
}
|
||||
if _, err := RESTClientFor(&Config{Host: "127.0.0.1", Version: "v1beta1"}); err == nil {
|
||||
if _, err := RESTClientFor(&Config{Host: "127.0.0.1", Version: testapi.Version()}); err == nil {
|
||||
t.Errorf("unexpected non-error")
|
||||
}
|
||||
if _, err := RESTClientFor(&Config{Host: "127.0.0.1", Version: testapi.Version(), Codec: testapi.Codec()}); err != nil {
|
||||
@@ -85,17 +79,17 @@ func TestValidatesHostParameter(t *testing.T) {
|
||||
URL string
|
||||
Err bool
|
||||
}{
|
||||
{"127.0.0.1", "", "http://127.0.0.1/v1beta1/", false},
|
||||
{"127.0.0.1:8080", "", "http://127.0.0.1:8080/v1beta1/", false},
|
||||
{"foo.bar.com", "", "http://foo.bar.com/v1beta1/", false},
|
||||
{"http://host/prefix", "", "http://host/prefix/v1beta1/", false},
|
||||
{"http://host", "", "http://host/v1beta1/", false},
|
||||
{"http://host", "/", "http://host/v1beta1/", false},
|
||||
{"http://host", "/other", "http://host/other/v1beta1/", false},
|
||||
{"127.0.0.1", "", "http://127.0.0.1/" + testapi.Version() + "/", false},
|
||||
{"127.0.0.1:8080", "", "http://127.0.0.1:8080/" + testapi.Version() + "/", false},
|
||||
{"foo.bar.com", "", "http://foo.bar.com/" + testapi.Version() + "/", false},
|
||||
{"http://host/prefix", "", "http://host/prefix/" + testapi.Version() + "/", false},
|
||||
{"http://host", "", "http://host/" + testapi.Version() + "/", false},
|
||||
{"http://host", "/", "http://host/" + testapi.Version() + "/", false},
|
||||
{"http://host", "/other", "http://host/other/" + testapi.Version() + "/", false},
|
||||
{"host/server", "", "", true},
|
||||
}
|
||||
for i, testCase := range testCases {
|
||||
c, err := RESTClientFor(&Config{Host: testCase.Host, Prefix: testCase.Prefix, Version: "v1beta1", Codec: testapi.Codec()})
|
||||
c, err := RESTClientFor(&Config{Host: testCase.Host, Prefix: testCase.Prefix, Version: testapi.Version(), Codec: testapi.Codec()})
|
||||
switch {
|
||||
case err == nil && testCase.Err:
|
||||
t.Errorf("expected error but was nil")
|
||||
|
Reference in New Issue
Block a user