Merge pull request #10892 from nikhiljindal/beta1

Removing references to pre v1beta3 apis in code
pull/6/head
Vish Kannan 2015-07-23 17:05:43 -07:00
commit 136d53466a
20 changed files with 60 additions and 112 deletions

View File

@ -468,7 +468,6 @@ runTests() {
### Printing pod templates works
kubectl get podtemplates "${kube_flags[@]}"
### Display of an object which doesn't existing in v1beta1 and v1beta2 works
[[ "$(kubectl get podtemplates -o yaml "${kube_flags[@]}" | grep nginx)" ]]
### Delete nginx pod template by name
@ -738,20 +737,6 @@ __EOF__
# Post-condition: node is schedulable
kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" '<no value>'
###########
# Nodes #
###########
if [[ "${version}" = "v1beta1" ]] || [[ "${version}" = "v1beta2" ]]; then
kube::log::status "Testing kubectl(${version}:nodes)"
kube::test::get_object_assert nodes "{{range.items}}{{$id_field}}:{{end}}" '127.0.0.1:'
kube::test::get_object_assert nodes '{{.kind}}' 'List'
kube::test::describe_object_assert nodes "127.0.0.1" "Name:" "Conditions:" "Addresses:" "Capacity:" "Pods:"
fi
#####################
# Retrieve multiple #

View File

@ -66,8 +66,7 @@ type typeMeta struct {
// can be mapped with the provided MetadataAccessor and Codec interfaces.
//
// The resource name of a Kind is defined as the lowercase,
// English-plural version of the Kind string in v1beta3 and onwards,
// and as the camelCase version of the name in v1beta1 and v1beta2.
// English-plural version of the Kind string.
// When converting from resource to Kind, the singular version of the
// resource name is also accepted for convenience.
//

View File

@ -23,6 +23,7 @@ import (
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
@ -202,7 +203,7 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
ev.ValueFrom = &api.EnvVarSource{}
ev.ValueFrom.FieldRef = &api.ObjectFieldSelector{}
versions := []string{"v1beta1", "v1beta2", "v1beta3"}
versions := registered.RegisteredVersions
ev.ValueFrom.FieldRef.APIVersion = versions[c.Rand.Intn(len(versions))]
ev.ValueFrom.FieldRef.FieldPath = c.RandString()

View File

@ -35,24 +35,13 @@ type RootPaths struct {
Paths []string `json:"paths"`
}
// preV1Beta3 returns true if the provided API version is an API introduced before v1beta3.
func PreV1Beta3(version string) bool {
return version == "v1beta1" || version == "v1beta2"
}
// TODO: remove me when watch is refactored
func LabelSelectorQueryParam(version string) string {
if PreV1Beta3(version) {
return "labels"
}
return "labelSelector"
}
// TODO: remove me when watch is refactored
func FieldSelectorQueryParam(version string) string {
if PreV1Beta3(version) {
return "fields"
}
return "fieldSelector"
}

View File

@ -164,15 +164,13 @@ func (c *testClient) ValidateCommon(t *testing.T, err error) {
// buildResourcePath is a convenience function for knowing if a namespace should be in a path param or not
func buildResourcePath(namespace, resource string) string {
if len(namespace) > 0 {
if !(testapi.Version() == "v1beta1" || testapi.Version() == "v1beta2") {
return path.Join("namespaces", namespace, resource)
}
return path.Join("namespaces", namespace, resource)
}
return resource
}
// buildQueryValues is a convenience function for knowing if a namespace should be in a query param or not
func buildQueryValues(namespace string, query url.Values) url.Values {
func buildQueryValues(query url.Values) url.Values {
v := url.Values{}
if query != nil {
for key, values := range query {
@ -181,11 +179,6 @@ func buildQueryValues(namespace string, query url.Values) url.Values {
}
}
}
if len(namespace) > 0 {
if api.PreV1Beta3(testapi.Version()) {
v.Set("namespace", namespace)
}
}
return v
}

View File

@ -27,7 +27,7 @@ import (
func TestListEndpoints(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("endpoints", ns, ""), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("endpoints", ns, ""), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200,
Body: &api.EndpointsList{
Items: []api.Endpoints{
@ -49,7 +49,7 @@ func TestListEndpoints(t *testing.T) {
func TestGetEndpoints(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("endpoints", ns, "endpoint-1"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("endpoints", ns, "endpoint-1"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: &api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "endpoint-1"}}},
}
response, err := c.Setup().Endpoints(ns).Get("endpoint-1")

View File

@ -192,8 +192,5 @@ func (e *events) GetFieldSelector(involvedObjectName, involvedObjectNamespace, i
// Returns the appropriate field label to use for name of the involved object as per the given API version.
func getInvolvedObjectNameFieldLabel(version string) string {
if api.PreV1Beta3(version) {
return "involvedObject.id"
}
return "involvedObject.name"
}

View File

@ -57,7 +57,7 @@ func TestLimitRangeCreate(t *testing.T) {
Request: testRequest{
Method: "POST",
Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: limitRange,
},
Response: Response{StatusCode: 200, Body: limitRange},
@ -93,7 +93,7 @@ func TestLimitRangeGet(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, "abc"),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: limitRange},
@ -117,7 +117,7 @@ func TestLimitRangeList(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: limitRangeList},
@ -150,7 +150,7 @@ func TestLimitRangeUpdate(t *testing.T) {
},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, "abc"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, "abc"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: limitRange},
}
response, err := c.Setup().LimitRanges(ns).Update(limitRange)
@ -180,7 +180,7 @@ func TestInvalidLimitRangeUpdate(t *testing.T) {
},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, "abc"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, "abc"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: limitRange},
}
_, err := c.Setup().LimitRanges(ns).Update(limitRange)
@ -192,7 +192,7 @@ func TestInvalidLimitRangeUpdate(t *testing.T) {
func TestLimitRangeDelete(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getLimitRangesResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().LimitRanges(ns).Delete("foo")

View File

@ -49,12 +49,8 @@ func newNodes(c *Client) *nodes {
return &nodes{c}
}
// resourceName returns node's URL resource name based on resource version.
// Uses "minions" as the URL resource name for v1beta1 and v1beta2.
// resourceName returns node's URL resource name.
func (c *nodes) resourceName() string {
if api.PreV1Beta3(c.r.APIVersion()) {
return "minions"
}
return "nodes"
}

View File

@ -44,13 +44,12 @@ func TestListMinions(t *testing.T) {
}
func TestListMinionsLabels(t *testing.T) {
ns := api.NamespaceNone
labelSelectorQueryParamName := api.LabelSelectorQueryParam(testapi.Version())
c := &testClient{
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getNodesResourceName(), "", ""),
Query: buildQueryValues(ns, url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Query: buildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Response: Response{
StatusCode: 200,
Body: &api.NodeList{

View File

@ -50,7 +50,7 @@ func TestPersistentVolumeCreate(t *testing.T) {
Request: testRequest{
Method: "POST",
Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", ""),
Query: buildQueryValues("", nil),
Query: buildQueryValues(nil),
Body: pv,
},
Response: Response{StatusCode: 200, Body: pv},
@ -79,7 +79,7 @@ func TestPersistentVolumeGet(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "abc"),
Query: buildQueryValues("", nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: persistentVolume},
@ -101,7 +101,7 @@ func TestPersistentVolumeList(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", ""),
Query: buildQueryValues("", nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: persistentVolumeList},
@ -126,7 +126,7 @@ func TestPersistentVolumeUpdate(t *testing.T) {
},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "abc"), Query: buildQueryValues("", nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "abc"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: persistentVolume},
}
response, err := c.Setup().PersistentVolumes().Update(persistentVolume)
@ -156,7 +156,7 @@ func TestPersistentVolumeStatusUpdate(t *testing.T) {
Request: testRequest{
Method: "PUT",
Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "abc") + "/status",
Query: buildQueryValues("", nil)},
Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: persistentVolume},
}
response, err := c.Setup().PersistentVolumes().UpdateStatus(persistentVolume)
@ -165,7 +165,7 @@ func TestPersistentVolumeStatusUpdate(t *testing.T) {
func TestPersistentVolumeDelete(t *testing.T) {
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "foo"), Query: buildQueryValues("", nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPersistentVolumesResoureName(), "", "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().PersistentVolumes().Delete("foo")

View File

@ -54,7 +54,7 @@ func TestPersistentVolumeClaimCreate(t *testing.T) {
Request: testRequest{
Method: "POST",
Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: pv,
},
Response: Response{StatusCode: 200, Body: pv},
@ -87,7 +87,7 @@ func TestPersistentVolumeClaimGet(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc"),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: persistentVolumeClaim},
@ -110,7 +110,7 @@ func TestPersistentVolumeClaimList(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: persistentVolumeList},
@ -139,7 +139,7 @@ func TestPersistentVolumeClaimUpdate(t *testing.T) {
},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: persistentVolumeClaim},
}
response, err := c.Setup().PersistentVolumeClaims(ns).Update(persistentVolumeClaim)
@ -172,7 +172,7 @@ func TestPersistentVolumeClaimStatusUpdate(t *testing.T) {
Request: testRequest{
Method: "PUT",
Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "abc") + "/status",
Query: buildQueryValues(ns, nil)},
Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: persistentVolumeClaim},
}
response, err := c.Setup().PersistentVolumeClaims(ns).UpdateStatus(persistentVolumeClaim)
@ -182,7 +182,7 @@ func TestPersistentVolumeClaimStatusUpdate(t *testing.T) {
func TestPersistentVolumeClaimDelete(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPersistentVolumeClaimsResoureName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().PersistentVolumeClaims(ns).Delete("foo")

View File

@ -43,7 +43,7 @@ func TestPodTemplateCreate(t *testing.T) {
Request: testRequest{
Method: "POST",
Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: &podTemplate,
},
Response: Response{StatusCode: 200, Body: &podTemplate},
@ -66,7 +66,7 @@ func TestPodTemplateGet(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, "abc"),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: podTemplate},
@ -92,7 +92,7 @@ func TestPodTemplateList(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: podTemplateList},
@ -112,7 +112,7 @@ func TestPodTemplateUpdate(t *testing.T) {
Template: api.PodTemplateSpec{},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, "abc"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, "abc"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: podTemplate},
}
response, err := c.Setup().PodTemplates(ns).Update(podTemplate)
@ -122,7 +122,7 @@ func TestPodTemplateUpdate(t *testing.T) {
func TestPodTemplateDelete(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().PodTemplates(ns).Delete("foo", nil)

View File

@ -29,7 +29,7 @@ import (
func TestListEmptyPods(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("pods", ns, ""), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("pods", ns, ""), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: &api.PodList{}},
}
podList, err := c.Setup().Pods(ns).List(labels.Everything(), fields.Everything())
@ -39,7 +39,7 @@ func TestListEmptyPods(t *testing.T) {
func TestListPods(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("pods", ns, ""), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("pods", ns, ""), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200,
Body: &api.PodList{
Items: []api.Pod{
@ -69,7 +69,7 @@ func TestListPodsLabels(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath("pods", ns, ""),
Query: buildQueryValues(ns, url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Query: buildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Response: Response{
StatusCode: 200,
Body: &api.PodList{
@ -99,7 +99,7 @@ func TestListPodsLabels(t *testing.T) {
func TestGetPod(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "GET", Path: testapi.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{
StatusCode: 200,
Body: &api.Pod{
@ -133,7 +133,7 @@ func TestGetPodWithNoName(t *testing.T) {
func TestDeletePod(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().Pods(ns).Delete("foo", nil)
@ -154,7 +154,7 @@ func TestCreatePod(t *testing.T) {
},
}
c := &testClient{
Request: testRequest{Method: "POST", Path: testapi.ResourcePath("pods", ns, ""), Query: buildQueryValues(ns, nil), Body: requestPod},
Request: testRequest{Method: "POST", Path: testapi.ResourcePath("pods", ns, ""), Query: buildQueryValues(nil), Body: requestPod},
Response: Response{
StatusCode: 200,
Body: requestPod,
@ -180,7 +180,7 @@ func TestUpdatePod(t *testing.T) {
},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath("pods", ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: requestPod},
}
receivedPod, err := c.Setup().Pods(ns).Update(requestPod)

View File

@ -63,7 +63,7 @@ func TestListControllers(t *testing.T) {
func TestGetController(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "GET", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{
StatusCode: 200,
Body: &api.ReplicationController{
@ -102,7 +102,7 @@ func TestUpdateController(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{
StatusCode: 200,
Body: &api.ReplicationController{
@ -127,7 +127,7 @@ func TestUpdateController(t *testing.T) {
func TestDeleteController(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getRCResourceName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().ReplicationControllers(ns).Delete("foo")
@ -140,7 +140,7 @@ func TestCreateController(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "foo"},
}
c := &testClient{
Request: testRequest{Method: "POST", Path: testapi.ResourcePath(getRCResourceName(), ns, ""), Body: requestController, Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "POST", Path: testapi.ResourcePath(getRCResourceName(), ns, ""), Body: requestController, Query: buildQueryValues(nil)},
Response: Response{
StatusCode: 200,
Body: &api.ReplicationController{

View File

@ -53,7 +53,7 @@ func TestResourceQuotaCreate(t *testing.T) {
Request: testRequest{
Method: "POST",
Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: resourceQuota,
},
Response: Response{StatusCode: 200, Body: resourceQuota},
@ -85,7 +85,7 @@ func TestResourceQuotaGet(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, "abc"),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: resourceQuota},
@ -109,7 +109,7 @@ func TestResourceQuotaList(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, ""),
Query: buildQueryValues(ns, nil),
Query: buildQueryValues(nil),
Body: nil,
},
Response: Response{StatusCode: 200, Body: resourceQuotaList},
@ -138,7 +138,7 @@ func TestResourceQuotaUpdate(t *testing.T) {
},
}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, "abc"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, "abc"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: resourceQuota},
}
response, err := c.Setup().ResourceQuotas(ns).Update(resourceQuota)
@ -168,7 +168,7 @@ func TestResourceQuotaStatusUpdate(t *testing.T) {
Request: testRequest{
Method: "PUT",
Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, "abc") + "/status",
Query: buildQueryValues(ns, nil)},
Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: resourceQuota},
}
response, err := c.Setup().ResourceQuotas(ns).UpdateStatus(resourceQuota)
@ -178,7 +178,7 @@ func TestResourceQuotaStatusUpdate(t *testing.T) {
func TestResourceQuotaDelete(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getResourceQuotasResoureName(), ns, "foo"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().ResourceQuotas(ns).Delete("foo")

View File

@ -31,7 +31,7 @@ func TestListServices(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath("services", ns, ""),
Query: buildQueryValues(ns, nil)},
Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200,
Body: &api.ServiceList{
Items: []api.Service{
@ -65,7 +65,7 @@ func TestListServicesLabels(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath("services", ns, ""),
Query: buildQueryValues(ns, url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Query: buildQueryValues(url.Values{labelSelectorQueryParamName: []string{"foo=bar,name=baz"}})},
Response: Response{StatusCode: 200,
Body: &api.ServiceList{
Items: []api.Service{
@ -100,7 +100,7 @@ func TestGetService(t *testing.T) {
Request: testRequest{
Method: "GET",
Path: testapi.ResourcePath("services", ns, "1"),
Query: buildQueryValues(ns, nil)},
Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
}
response, err := c.Setup().Services(ns).Get("1")
@ -125,7 +125,7 @@ func TestCreateService(t *testing.T) {
Method: "POST",
Path: testapi.ResourcePath("services", ns, ""),
Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}},
Query: buildQueryValues(ns, nil)},
Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}}},
}
response, err := c.Setup().Services(ns).Create(&api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1"}})
@ -136,7 +136,7 @@ func TestUpdateService(t *testing.T) {
ns := api.NamespaceDefault
svc := &api.Service{ObjectMeta: api.ObjectMeta{Name: "service-1", ResourceVersion: "1"}}
c := &testClient{
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath("services", ns, "service-1"), Body: svc, Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "PUT", Path: testapi.ResourcePath("services", ns, "service-1"), Body: svc, Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200, Body: svc},
}
response, err := c.Setup().Services(ns).Update(svc)
@ -146,7 +146,7 @@ func TestUpdateService(t *testing.T) {
func TestDeleteService(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath("services", ns, "1"), Query: buildQueryValues(ns, nil)},
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath("services", ns, "1"), Query: buildQueryValues(nil)},
Response: Response{StatusCode: 200},
}
err := c.Setup().Services(ns).Delete("1")

View File

@ -19,6 +19,7 @@ package testclient
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
@ -131,7 +132,7 @@ func (c *Fake) ServerVersion() (*version.Info, error) {
func (c *Fake) ServerAPIVersions() (*api.APIVersions, error) {
c.Actions = append(c.Actions, FakeAction{Action: "get-apiversions", Value: nil})
return &api.APIVersions{Versions: []string{"v1beta1", "v1beta2"}}, nil
return &api.APIVersions{Versions: registered.RegisteredVersions}, nil
}
func (c *Fake) ComponentStatuses() client.ComponentStatusInterface {

View File

@ -69,14 +69,10 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName string) er
func getSelfLink(name, namespace string) string {
var selfLink string
if api.PreV1Beta3(latest.Version) {
selfLink = fmt.Sprintf("/api/"+latest.Version+"/pods/%s?namespace=%s", name, namespace)
} else {
if len(namespace) == 0 {
namespace = api.NamespaceDefault
}
selfLink = fmt.Sprintf("/api/"+latest.Version+"/pods/namespaces/%s/%s", name, namespace)
if len(namespace) == 0 {
namespace = api.NamespaceDefault
}
selfLink = fmt.Sprintf("/api/"+latest.Version+"/pods/namespaces/%s/%s", name, namespace)
return selfLink
}

View File

@ -488,8 +488,6 @@ func (m *Master) init(c *Config) {
"replicationControllers": controllerStorage,
"services": service.NewStorage(m.serviceRegistry, m.nodeRegistry, m.endpointRegistry, serviceClusterIPAllocator, serviceNodePortAllocator, c.ClusterName),
"endpoints": endpointsStorage,
"minions": nodeStorage,
"minions/status": nodeStatusStorage,
"nodes": nodeStorage,
"nodes/status": nodeStatusStorage,
"events": event.NewStorage(eventRegistry),
@ -762,9 +760,6 @@ func (m *Master) defaultAPIGroupVersion() *apiserver.APIGroupVersion {
func (m *Master) api_v1beta3() *apiserver.APIGroupVersion {
storage := make(map[string]rest.Storage)
for k, v := range m.storage {
if k == "minions" || k == "minions/status" {
continue
}
storage[strings.ToLower(k)] = v
}
version := m.defaultAPIGroupVersion()
@ -778,9 +773,6 @@ func (m *Master) api_v1beta3() *apiserver.APIGroupVersion {
func (m *Master) api_v1() *apiserver.APIGroupVersion {
storage := make(map[string]rest.Storage)
for k, v := range m.storage {
if k == "minions" || k == "minions/status" {
continue
}
storage[strings.ToLower(k)] = v
}
version := m.defaultAPIGroupVersion()