Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI request when namespace is in argument and part of the path #12720

Merged
merged 3 commits into from Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/12720.txt
@@ -0,0 +1,3 @@
```release-note:bug
cli: fixes CLI requests when namespace is both provided as argument and part of the path
```
20 changes: 18 additions & 2 deletions command/kv_helpers.go
Expand Up @@ -110,8 +110,24 @@ func addPrefixToVKVPath(p, mountPath, apiPrefix string) string {
case p == mountPath, p == strings.TrimSuffix(mountPath, "/"):
return path.Join(mountPath, apiPrefix)
default:
p = strings.TrimPrefix(p, mountPath)
return path.Join(mountPath, apiPrefix, p)
tp := strings.TrimPrefix(p, mountPath)
for {
ccapurso marked this conversation as resolved.
Show resolved Hide resolved
// If the entire mountPath is included in the path, we are done
if tp != p {
break
}
// Trim the parts of the mountPath that are not included in the
// path, for example, in cases where the mountPath contains
// namespaces which are not included in the path.
partialMountPath := strings.SplitN(mountPath, "/", 2)
if len(partialMountPath) == 1 || partialMountPath[1] == ""{
ccapurso marked this conversation as resolved.
Show resolved Hide resolved
break
}
mountPath = partialMountPath[1]
tp = strings.TrimPrefix(p, mountPath)
}

return path.Join(mountPath, apiPrefix, tp)
}
}

Expand Down