Merge pull request #30958 from TerryHowe/repo-update-cmd-mutex

fix: repo update cmd mutex
pull/30968/head
Matt Farina 4 months ago committed by GitHub
commit 919933553b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -113,14 +113,19 @@ func updateCharts(repos []*repo.ChartRepository, out io.Writer) error {
var wg sync.WaitGroup
failRepoURLChan := make(chan string, len(repos))
writeMutex := sync.Mutex{}
for _, re := range repos {
wg.Add(1)
go func(re *repo.ChartRepository) {
defer wg.Done()
if _, err := re.DownloadIndexFile(); err != nil {
writeMutex.Lock()
defer writeMutex.Unlock()
fmt.Fprintf(out, "...Unable to get an update from the %q chart repository (%s):\n\t%s\n", re.Config.Name, re.Config.URL, err)
failRepoURLChan <- re.Config.URL
} else {
writeMutex.Lock()
defer writeMutex.Unlock()
fmt.Fprintf(out, "...Successfully got an update from the %q chart repository\n", re.Config.Name)
}
}(re)

Loading…
Cancel
Save