mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 12:11:43 +00:00
Updating unit tests so that they pass with v1beta3 api
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
@@ -74,3 +75,34 @@ func SelfLink(resource, name string) string {
|
||||
}
|
||||
return fmt.Sprintf("/api/%s/%s/%s", Version(), resource, name)
|
||||
}
|
||||
|
||||
// Returns the appropriate path for the given resource, namespace and name.
|
||||
// For ex, this is of the form:
|
||||
// /api/v1beta1/pods/pod0 for v1beta1 and
|
||||
// /api/v1beta3/namespaces/foo/pods/pod0 for v1beta3.
|
||||
func ResourcePath(resource, namespace, name string) string {
|
||||
path := "/api/" + Version()
|
||||
if !api.PreV1Beta3(Version()) && namespace != "" {
|
||||
path = path + "/namespaces/" + namespace
|
||||
}
|
||||
if resource != "" {
|
||||
path = path + "/" + resource
|
||||
}
|
||||
if name != "" {
|
||||
path = path + "/" + name
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// Returns the appropriate path along with the query params for the given resource, namespace and name.
|
||||
// For ex, this is of the form:
|
||||
// /api/v1beta1/pods/pod0?namespace=foo for v1beta1 and
|
||||
// /api/v1beta3/namespaces/foo/pods/pod0 for v1beta3.
|
||||
func ResourcePathWithQueryParams(resource, namespace, name string) string {
|
||||
path := ResourcePath(resource, namespace, name)
|
||||
// Add namespace as query param for pre v1beta3.
|
||||
if api.PreV1Beta3(Version()) {
|
||||
path = path + "?namespace=" + namespace
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
Reference in New Issue
Block a user