Skip to content

Commit

Permalink
Allow istioctl to be used on pods with periods in their name (istio#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
esnible authored and istio-testing committed Aug 6, 2019
1 parent 40ff852 commit 1c5a959
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions istioctl/pkg/util/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
//InferPodInfo Uses proxyName to infer namespace if the passed proxyName contains namespace information.
// Otherwise uses the namespace value passed into the function
func InferPodInfo(proxyName, namespace string) (string, string) {
parsedProxy := strings.Split(proxyName, ".")

if len(parsedProxy) == 1 {
separator := strings.LastIndex(proxyName, ".")
if separator < 0 {
return proxyName, namespace
}
return parsedProxy[0], parsedProxy[1]

return proxyName[0:separator], proxyName[separator+1:]
}

//HandleNamespace returns the defaultNamespace if the namespace is empty
Expand Down
12 changes: 12 additions & 0 deletions istioctl/pkg/util/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ func TestInferPodInfo(t *testing.T) {
wantPodName: "istio-ingressgateway-8d9697654-qdzgh",
wantNamespace: "kube-system",
},
{
proxyName: "istio-security-post-install-1.2.2-bm9w2.istio-system",
namespace: "istio-system",
wantPodName: "istio-security-post-install-1.2.2-bm9w2",
wantNamespace: "istio-system",
},
{
proxyName: "istio-security-post-install-1.2.2-bm9w2.istio-system",
namespace: "",
wantPodName: "istio-security-post-install-1.2.2-bm9w2",
wantNamespace: "istio-system",
},
}
for _, tt := range tests {
t.Run(strings.Split(tt.proxyName, ".")[0], func(t *testing.T) {
Expand Down

0 comments on commit 1c5a959

Please sign in to comment.