@@ -142,7 +142,7 @@ func (m *Manager) Build() error {
142
142
}
143
143
144
144
// Now we need to fetch every package here into charts/
145
- return m .downloadAll (lock .Dependencies )
145
+ return m .downloadAll (lock .Dependencies , nil )
146
146
}
147
147
148
148
// Update updates a local charts directory.
@@ -192,13 +192,13 @@ func (m *Manager) Update() error {
192
192
193
193
// Now we need to find out which version of a chart best satisfies the
194
194
// dependencies in the Chart.yaml
195
- lock , err := m .resolve (req , repoNames )
195
+ lock , urls , err := m .resolve (req , repoNames )
196
196
if err != nil {
197
197
return err
198
198
}
199
199
200
200
// Now we need to fetch every package here into charts/
201
- if err := m .downloadAll (lock .Dependencies ); err != nil {
201
+ if err := m .downloadAll (lock .Dependencies , urls ); err != nil {
202
202
return err
203
203
}
204
204
@@ -231,7 +231,7 @@ func (m *Manager) loadChartDir() (*chart.Chart, error) {
231
231
// resolve takes a list of dependencies and translates them into an exact version to download.
232
232
//
233
233
// This returns a lock file, which has all of the dependencies normalized to a specific version.
234
- func (m * Manager ) resolve (req []* chart.Dependency , repoNames map [string ]string ) (* chart.Lock , error ) {
234
+ func (m * Manager ) resolve (req []* chart.Dependency , repoNames map [string ]string ) (* chart.Lock , map [ string ] string , error ) {
235
235
res := resolver .New (m .ChartPath , m .RepositoryCache , m .RegistryClient )
236
236
return res .Resolve (req , repoNames )
237
237
}
@@ -240,7 +240,7 @@ func (m *Manager) resolve(req []*chart.Dependency, repoNames map[string]string)
240
240
//
241
241
// It will delete versions of the chart that exist on disk and might cause
242
242
// a conflict.
243
- func (m * Manager ) downloadAll (deps []* chart.Dependency ) error {
243
+ func (m * Manager ) downloadAll (deps []* chart.Dependency , urls map [ string ] string ) error {
244
244
repos , err := m .loadChartRepositories ()
245
245
if err != nil {
246
246
return err
@@ -313,7 +313,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
313
313
314
314
// Any failure to resolve/download a chart should fail:
315
315
// https://github.com/helm/helm/issues/1439
316
- churl , username , password , insecureskiptlsverify , passcredentialsall , caFile , certFile , keyFile , err := m .findChartURL (dep .Name , dep .Version , dep .Repository , repos )
316
+ churl , username , password , insecureskiptlsverify , passcredentialsall , caFile , certFile , keyFile , err := m .findChartURL (dep .Name , dep .Version , dep .Repository , repos , urls )
317
317
if err != nil {
318
318
saveError = errors .Wrapf (err , "could not find %s" , churl )
319
319
break
@@ -502,6 +502,7 @@ func (m *Manager) ensureMissingRepos(repoNames map[string]string, deps []*chart.
502
502
503
503
var ru []* repo.Entry
504
504
505
+ Outer:
505
506
for _ , dd := range deps {
506
507
507
508
// If the chart is in the local charts directory no repository needs
@@ -529,6 +530,14 @@ func (m *Manager) ensureMissingRepos(repoNames map[string]string, deps []*chart.
529
530
530
531
repoNames [dd .Name ] = rn
531
532
533
+ // If repository is already present don't add to array. This will skip
534
+ // unnecessary index file downloading improving performance.
535
+ for _ , item := range ru {
536
+ if item .URL == dd .Repository {
537
+ continue Outer
538
+ }
539
+ }
540
+
532
541
// Assuming the repository is generally available. For Helm managed
533
542
// access controls the repository needs to be added through the user
534
543
// managed system. This path will work for public charts, like those
@@ -703,7 +712,7 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error {
703
712
// repoURL is the repository to search
704
713
//
705
714
// If it finds a URL that is "relative", it will prepend the repoURL.
706
- func (m * Manager ) findChartURL (name , version , repoURL string , repos map [string ]* repo.ChartRepository ) (url , username , password string , insecureskiptlsverify , passcredentialsall bool , caFile , certFile , keyFile string , err error ) {
715
+ func (m * Manager ) findChartURL (name , version , repoURL string , repos map [string ]* repo.ChartRepository , urls map [ string ] string ) (url , username , password string , insecureskiptlsverify , passcredentialsall bool , caFile , certFile , keyFile string , err error ) {
707
716
if registry .IsOCI (repoURL ) {
708
717
return fmt .Sprintf ("%s/%s:%s" , repoURL , name , version ), "" , "" , false , false , "" , "" , "" , nil
709
718
}
@@ -735,7 +744,13 @@ func (m *Manager) findChartURL(name, version, repoURL string, repos map[string]*
735
744
return
736
745
}
737
746
}
738
- url , err = repo .FindChartInRepoURL (repoURL , name , version , certFile , keyFile , caFile , m .Getters )
747
+
748
+ if _ , ok := urls [name ]; ok {
749
+ url = urls [name ]
750
+ } else {
751
+ url , err = repo .FindChartInRepoURL (repoURL , name , version , certFile , keyFile , caFile , m .Getters )
752
+ }
753
+
739
754
if err == nil {
740
755
return url , username , password , false , false , "" , "" , "" , err
741
756
}
0 commit comments