Skip to content

Commit

Permalink
Update index.go
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: liangxiaolei5 <[email protected]>
  • Loading branch information
wutongjie23hao authored and liangxiaolei5 committed Jan 31, 2024
1 parent 90e47f6 commit 6c12482
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/chartmuseum/server/multitenant/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ func (server *MultiTenantServer) getIndexFile(log cm_logger.LoggingFn, repo stri
entry.RepoLock.Lock()
defer entry.RepoLock.Unlock()

allChartsCount := 0
if len(entry.RepoIndex.Entries) != 0 || server.CacheInterval != 0 {
for _, chVersions := range entry.RepoIndex.Entries {
allChartsCount += len(chVersions)
}
}
if len(entry.RepoIndex.Entries) != 0 || server.CacheInterval != 0 {
allObjects, err := server.fetchChartsInStorage(log, repo)
if err != nil || allChartsCount != len(allObjects) {
entry.RepoIndex.Entries = map[string]repo.ChartVersions{}
server.CacheInterval = 0
}
}

// if the always-regenerate-chart-index flag is set, we always update the index file
// and ignore the chart cache
if server.AlwaysRegenerateIndex /* the flag is set */ ||
Expand Down

0 comments on commit 6c12482

Please sign in to comment.