1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-01 15:18:20 +00:00

Allow types that start with cluster or project

This commit is contained in:
Darren Shepherd
2018-03-22 15:53:52 -07:00
parent b5aef8d08d
commit bcb8076caa

View File

@@ -142,7 +142,11 @@ func versionsForPath(schemas *types.Schemas, path string) []types.APIVersion {
var matchedVersion []types.APIVersion
for _, version := range schemas.Versions() {
if strings.HasPrefix(path, version.Path) {
matchedVersion = append(matchedVersion, version)
afterPath := path[len(version.Path):]
// if version.Path is /v3/cluster allow /v3/clusters but not /v3/clusterstuff
if len(afterPath) < 3 || strings.Contains(afterPath[:3], "/") {
matchedVersion = append(matchedVersion, version)
}
}
}
sort.Slice(matchedVersion, func(i, j int) bool {