Remove use of testapi codecs, selflink, resourcepath functions
This commit is contained in:
@@ -47,8 +47,7 @@ import (
|
||||
"k8s.io/apiserver/pkg/authorization/authorizerfactory"
|
||||
"k8s.io/apiserver/plugin/pkg/authenticator/token/tokentest"
|
||||
"k8s.io/apiserver/plugin/pkg/authenticator/token/webhook"
|
||||
"k8s.io/client-go/tools/clientcmd/api/v1"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
v1 "k8s.io/client-go/tools/clientcmd/api/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
@@ -94,26 +93,45 @@ func getTestWebhookTokenAuth(serverURL string) (authenticator.Request, error) {
|
||||
}
|
||||
|
||||
func path(resource, namespace, name string) string {
|
||||
return testapi.Default.ResourcePath(resource, namespace, name)
|
||||
return pathWithPrefix("", resource, namespace, name)
|
||||
}
|
||||
|
||||
func pathWithPrefix(prefix, resource, namespace, name string) string {
|
||||
return testapi.Default.ResourcePathWithPrefix(prefix, resource, namespace, name)
|
||||
path := "/api/v1"
|
||||
if prefix != "" {
|
||||
path = path + "/" + prefix
|
||||
}
|
||||
if namespace != "" {
|
||||
path = path + "/namespaces/" + namespace
|
||||
}
|
||||
// Resource names are lower case.
|
||||
resource = strings.ToLower(resource)
|
||||
if resource != "" {
|
||||
path = path + "/" + resource
|
||||
}
|
||||
if name != "" {
|
||||
path = path + "/" + name
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func pathWithSubResource(resource, namespace, name, subresource string) string {
|
||||
return testapi.Default.SubResourcePath(resource, namespace, name, subresource)
|
||||
path := pathWithPrefix("", resource, namespace, name)
|
||||
if subresource != "" {
|
||||
path = path + "/" + subresource
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func timeoutPath(resource, namespace, name string) string {
|
||||
return addTimeoutFlag(testapi.Default.ResourcePath(resource, namespace, name))
|
||||
return addTimeoutFlag(path(resource, namespace, name))
|
||||
}
|
||||
|
||||
// Bodies for requests used in subsequent tests.
|
||||
var aPod = `
|
||||
{
|
||||
"kind": "Pod",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"creationTimestamp": null%s
|
||||
@@ -131,7 +149,7 @@ var aPod = `
|
||||
var aRC = `
|
||||
{
|
||||
"kind": "ReplicationController",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"labels": {
|
||||
@@ -164,7 +182,7 @@ var aRC = `
|
||||
var aService = `
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a",
|
||||
"labels": {
|
||||
@@ -188,7 +206,7 @@ var aService = `
|
||||
var aNode = `
|
||||
{
|
||||
"kind": "Node",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -202,7 +220,7 @@ func aEvent(namespace string) string {
|
||||
return `
|
||||
{
|
||||
"kind": "Event",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -219,7 +237,7 @@ func aEvent(namespace string) string {
|
||||
var aBinding = `
|
||||
{
|
||||
"kind": "Binding",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -242,7 +260,7 @@ var emptyEndpoints = `
|
||||
var aEndpoints = `
|
||||
{
|
||||
"kind": "Endpoints",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "a"%s
|
||||
},
|
||||
@@ -267,7 +285,7 @@ var aEndpoints = `
|
||||
var deleteNow = `
|
||||
{
|
||||
"kind": "DeleteOptions",
|
||||
"apiVersion": "` + testapi.Groups[api.GroupName].GroupVersion().String() + `",
|
||||
"apiVersion": "v1",
|
||||
"gracePeriodSeconds": 0%s
|
||||
}
|
||||
`
|
||||
|
Reference in New Issue
Block a user