Fix selfLinks of pods started from manifests
This commit is contained in:
@@ -93,7 +93,7 @@ func getSelfLink(name, namespace string) string {
|
||||
if len(namespace) == 0 {
|
||||
namespace = metav1.NamespaceDefault
|
||||
}
|
||||
selfLink = fmt.Sprintf("/api/"+api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version+"/pods/namespaces/%s/%s", name, namespace)
|
||||
selfLink = fmt.Sprintf("/api/"+api.Registry.GroupOrDie(api.GroupName).GroupVersion.Version+"/namespaces/%s/pods/%s", namespace, name)
|
||||
return selfLink
|
||||
}
|
||||
|
||||
|
@@ -160,3 +160,31 @@ func TestDecodePodList(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSelfLink(t *testing.T) {
|
||||
var testCases = []struct {
|
||||
desc string
|
||||
name string
|
||||
namespace string
|
||||
expectedSelfLink string
|
||||
}{
|
||||
{
|
||||
desc: "No namespace specified",
|
||||
name: "foo",
|
||||
namespace: "",
|
||||
expectedSelfLink: "/api/v1/namespaces/default/pods/foo",
|
||||
},
|
||||
{
|
||||
desc: "Namespace specified",
|
||||
name: "foo",
|
||||
namespace: "bar",
|
||||
expectedSelfLink: "/api/v1/namespaces/bar/pods/foo",
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
selfLink := getSelfLink(testCase.name, testCase.namespace)
|
||||
if testCase.expectedSelfLink != selfLink {
|
||||
t.Errorf("%s: getSelfLink error, expected: %s, got: %s", testCase.desc, testCase.expectedSelfLink, selfLink)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user