scanReposForURL scans all repos to find which repo contains the given URL. This will attempt to find the given URL in all of the known repositories files. If the URL is found, this will return the repo entry that contained that URL. If all of the repos are checked, but the URL is not found, an Er
(u string, rf *repo.File)
| 558 | // will return the first one it finds. Order is determined by the order of repositories |
| 559 | // in the repositories.yaml file. |
| 560 | func (c *ChartDownloader) scanReposForURL(u string, rf *repo.File) (*repo.Entry, error) { |
| 561 | // FIXME: This is far from optimal. Larger installations and index files will |
| 562 | // incur a performance hit for this type of scanning. |
| 563 | for _, rc := range rf.Repositories { |
| 564 | r, err := repo.NewChartRepository(rc, c.Getters) |
| 565 | if err != nil { |
| 566 | return nil, err |
| 567 | } |
| 568 | |
| 569 | idxFile := filepath.Join(c.RepositoryCache, helmpath.CacheIndexFile(r.Config.Name)) |
| 570 | i, err := repo.LoadIndexFile(idxFile) |
| 571 | if err != nil { |
| 572 | return nil, fmt.Errorf("no cached repo found. (try 'helm repo update'): %w", err) |
| 573 | } |
| 574 | |
| 575 | for _, entry := range i.Entries { |
| 576 | for _, ver := range entry { |
| 577 | for _, dl := range ver.URLs { |
| 578 | if urlutil.Equal(u, dl) { |
| 579 | return rc, nil |
| 580 | } |
| 581 | } |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | // This means that there is no repo file for the given URL. |
| 586 | return nil, ErrNoOwnerRepo |
| 587 | } |
| 588 | |
| 589 | func loadRepoConfig(file string) (*repo.File, error) { |
| 590 | r, err := repo.LoadFile(file) |