Fix: Compare path properly when list repository in catalog. #1854
Signed-off-by: Sebastien Coavoux <alignak@pyseb.cx>
This commit is contained in:
parent
22a59f2512
commit
0567fa3c2a
1 changed files with 21 additions and 1 deletions
|
@ -39,7 +39,7 @@ func (reg *registry) Repositories(ctx context.Context, repos []string, last stri
|
|||
_, file := path.Split(repoPath)
|
||||
if file == "_layers" {
|
||||
repoPath = strings.TrimSuffix(repoPath, "/_layers")
|
||||
if repoPath > last {
|
||||
if pathGreaterThan(repoPath, last) {
|
||||
foundRepos = append(foundRepos, repoPath)
|
||||
}
|
||||
return ErrSkipDir
|
||||
|
@ -95,3 +95,23 @@ func (reg *registry) Enumerate(ctx context.Context, ingester func(string) error)
|
|||
return nil
|
||||
|
||||
}
|
||||
|
||||
func pathGreaterThan(pathX, pathY string) (b bool) {
|
||||
splitPathX := strings.SplitN(pathX, "/", 2)
|
||||
splitPathY := strings.SplitN(pathY, "/", 2)
|
||||
|
||||
if splitPathX[0] == splitPathY[0] {
|
||||
if len(splitPathX) == 1 && len(splitPathY) == 1 {
|
||||
return false
|
||||
} else if len(splitPathX) == 1 && len(splitPathY) != 1 {
|
||||
return false
|
||||
} else if len(splitPathX) != 1 && len(splitPathY) == 1 {
|
||||
return true
|
||||
}
|
||||
|
||||
return pathGreaterThan(splitPathX[1], splitPathY[1])
|
||||
|
||||
}
|
||||
|
||||
return splitPathX[0] > splitPathY[0]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue