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]>
  • Loading branch information
wutongjie23hao authored Jan 31, 2024
1 parent 90e47f6 commit d2ccb6b
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{}

Check failure on line 54 in pkg/chartmuseum/server/multitenant/index.go

View workflow job for this annotation

GitHub Actions / build

repo.ChartVersions is not a type
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 d2ccb6b

Please sign in to comment.