fix: GetNextRepository to use a list already scanned repositories as input (#3230)

Using just the last repository is not enough as in the case when it is deleted
(either by GC or some other way), GetNextRepository returns empty string
causing the generator to be marked completed without any errors.

An alternative would have been to start over from the first repository,
but this can take hours if multiple repositories need to be deleted,
not to mention the processing power and I/O and S3 load this could take.

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
Andrei Aaron
2025-07-04 19:12:18 +03:00
committed by GitHub
parent e8ac21c001
commit 80081bb012
10 changed files with 244 additions and 75 deletions
+3 -3
View File
@@ -19,7 +19,7 @@ type MockedImageStore struct {
InitRepoFn func(name string) error
ValidateRepoFn func(name string) (bool, error)
GetRepositoriesFn func() ([]string, error)
GetNextRepositoryFn func(repo string) (string, error)
GetNextRepositoryFn func(processedRepos map[string]struct{}) (string, error)
GetNextRepositoriesFn func(lastRepo string, maxEntries int, fn storageTypes.FilterRepoFunc) ([]string, bool, error)
GetImageTagsFn func(repo string) ([]string, error)
GetImageManifestFn func(repo string, reference string) ([]byte, godigest.Digest, string, error)
@@ -132,9 +132,9 @@ func (is MockedImageStore) GetRepositories() ([]string, error) {
return []string{}, nil
}
func (is MockedImageStore) GetNextRepository(repo string) (string, error) {
func (is MockedImageStore) GetNextRepository(processedRepos map[string]struct{}) (string, error) {
if is.GetNextRepositoryFn != nil {
return is.GetNextRepositoryFn(repo)
return is.GetNextRepositoryFn(processedRepos)
}
return "", nil