1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00

fix(gitops): update the git ref cache key from url to url and pat (#7841)

This commit is contained in:
Oscar Zhou 2022-10-11 18:31:21 +13:00 committed by GitHub
parent 724f1f63b7
commit c23b8b2816
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View file

@ -163,9 +163,10 @@ func (service *Service) LatestCommitID(repositoryURL, referenceName, username, p
// ListRefs will list target repository's references without cloning the repository
func (service *Service) ListRefs(repositoryURL, username, password string, hardRefresh bool) ([]string, error) {
refCacheKey := generateCacheKey(repositoryURL, password)
if service.cacheEnabled && hardRefresh {
// Should remove the cache explicitly, so that the following normal list can show the correct result
service.repoRefCache.Remove(repositoryURL)
service.repoRefCache.Remove(refCacheKey)
// Remove file caches pointed to the same repository
for _, fileCacheKey := range service.repoFileCache.Keys() {
key, ok := fileCacheKey.(string)
@ -179,7 +180,7 @@ func (service *Service) ListRefs(repositoryURL, username, password string, hardR
if service.repoRefCache != nil {
// Lookup the refs cache first
cache, ok := service.repoRefCache.Get(repositoryURL)
cache, ok := service.repoRefCache.Get(refCacheKey)
if ok {
refs, success := cache.([]string)
if success {
@ -211,7 +212,7 @@ func (service *Service) ListRefs(repositoryURL, username, password string, hardR
}
if service.cacheEnabled && service.repoRefCache != nil {
service.repoRefCache.Add(options.repositoryUrl, refs)
service.repoRefCache.Add(refCacheKey, refs)
}
return refs, nil
}