Skip to content

Commit d2ccb6b

Browse files
Update index.go
the chartversions of index.yaml should be equal to the length of chartversion objects in storage backend. if not equal, we should regenerate the index.yaml. Signed-off-by: Xiaolei.Liang <[email protected]>
1 parent 90e47f6 commit d2ccb6b

File tree

1 file changed

+14
-0
lines changed
  • pkg/chartmuseum/server/multitenant

1 file changed

+14
-0
lines changed

pkg/chartmuseum/server/multitenant/index.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ func (server *MultiTenantServer) getIndexFile(log cm_logger.LoggingFn, repo stri
4242
entry.RepoLock.Lock()
4343
defer entry.RepoLock.Unlock()
4444

45+
allChartsCount := 0
46+
if len(entry.RepoIndex.Entries) != 0 || server.CacheInterval != 0 {
47+
for _, chVersions := range entry.RepoIndex.Entries {
48+
allChartsCount += len(chVersions)
49+
}
50+
}
51+
if len(entry.RepoIndex.Entries) != 0 || server.CacheInterval != 0 {
52+
allObjects, err := server.fetchChartsInStorage(log, repo)
53+
if err != nil || allChartsCount != len(allObjects) {
54+
entry.RepoIndex.Entries = map[string]repo.ChartVersions{}
55+
server.CacheInterval = 0
56+
}
57+
}
58+
4559
// if the always-regenerate-chart-index flag is set, we always update the index file
4660
// and ignore the chart cache
4761
if server.AlwaysRegenerateIndex /* the flag is set */ ||

0 commit comments

Comments
 (0)