diff --git a/pkg/repo/v1/chartrepo.go b/pkg/repo/v1/chartrepo.go index deef7474e..acbede2f7 100644 --- a/pkg/repo/v1/chartrepo.go +++ b/pkg/repo/v1/chartrepo.go @@ -28,6 +28,7 @@ import ( "os" "path/filepath" "strings" + "sync" "helm.sh/helm/v4/internal/fileutil" "helm.sh/helm/v4/pkg/getter" @@ -53,6 +54,7 @@ type ChartRepository struct { IndexFile *IndexFile Client getter.Getter CachePath string + mutex sync.RWMutex } // NewChartRepository constructs ChartRepository @@ -77,6 +79,9 @@ func NewChartRepository(cfg *Entry, getters getter.Providers) (*ChartRepository, // DownloadIndexFile fetches the index from a repository. func (r *ChartRepository) DownloadIndexFile() (string, error) { + r.mutex.Lock() + defer r.mutex.Unlock() + indexURL, err := ResolveReferenceURL(r.Config.URL, "index.yaml") if err != nil { return "", err