Skip to content

Commit d01aa2c

Browse files
zaldrezaldre
andauthored
fix(storage): normalize repository names to '/' separators on Windows (#4188)
filepath.Rel returns OS-specific separators, so on Windows the repo walkers (GetRepositories, GetNextRepository, GetNextRepositories) produced backslash-separated names such as 'openshift4\ose-cli'. Those names fail FullNameRegexp validation in ValidateRepo, which only accepts '/' as a component separator, so every namespaced repository was silently dropped. As a result /v2/_catalog returned an empty list, and garbage collection, scrub, and metadb never saw any repositories. Convert each relative path with filepath.ToSlash (a no-op on Unix) before validation, matching the existing ToSlash usage elsewhere in imagestore.go. Signed-off-by: zaldre <zaldre@zaldre.com> Co-authored-by: zaldre <zaldre@zaldre.com>
1 parent 4cb8ea9 commit d01aa2c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/storage/imagestore/imagestore.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ func (is *ImageStore) GetNextRepositories(lastRepo string, maxEntries int, filte
310310
return nil //nolint:nilerr // ignore paths that are not under root dir
311311
}
312312

313+
rel = filepath.ToSlash(rel)
314+
313315
if ok, err := is.ValidateRepo(rel); !ok || err != nil {
314316
return nil //nolint:nilerr // ignore invalid repos
315317
}
@@ -384,6 +386,8 @@ func (is *ImageStore) GetRepositories() ([]string, error) {
384386
return nil //nolint:nilerr // ignore paths that are not under root dir
385387
}
386388

389+
rel = filepath.ToSlash(rel)
390+
387391
if ok, err := is.ValidateRepo(rel); !ok || err != nil {
388392
return nil //nolint:nilerr // ignore invalid repos
389393
}
@@ -435,6 +439,8 @@ func (is *ImageStore) GetNextRepository(processedRepos map[string]struct{}) (str
435439
return nil //nolint:nilerr // ignore paths not relative to root dir
436440
}
437441

442+
rel = filepath.ToSlash(rel)
443+
438444
if _, ok := processedRepos[rel]; ok {
439445
return nil // repo already processed
440446
}

0 commit comments

Comments
 (0)