Open Jefftree opened 2 months ago
I agree that the safest thing to achieve the goal is to exclude exact matches on prefix and prefix+slash. The required modification looks small.
Is this something you want? If so I'll open a PR.
+++ prefixSet := sets.NewString(keepPathPrefixes...)
for path, pathItem := range sp.Paths.Paths {
if !prefixes.HasPrefix(path) {
continue
}
+++ if !strings.HasSuffix(path, "/") {
+++ continue
+++ }
+++ if !prefixSet.Has(path) {
+++ continue
+++ }
ret.Paths.Paths[path] = pathItem
}
From a quick glance I don't think it's correct but seems close. Here's a useful test case
FilterSpecByPathsWithoutSideEffects([]{"/apis/group/v1beta1/"}, []{"/apis/group/v1"}, ...}
should return "" because despite v1 being a prefix of v1beta1, we should really be matching for "/apis/group/v1/...".
The current FilterSpecByPathsWithoutSideEffects behavior is wrong for paths without a trailing slash. See comment thread for more details: https://github.com/kubernetes/kubernetes/pull/123770/files#r1516319191
cc @liggitt