Fix the url being set by WithURL on the getters

The URL passed to the getter for WithURL needs to be a full URL
rather than a chart reference used at the CLI. For example,
bitnami/wordpress can point to the wordpress chart in the bitnami
repo where the bitnami repo is at https://charts.bitnami.com.
WithURL needs the full URL to the repo and not bitnami/wordpress.
This is important because getters use the full URL information.
In this case the http getter uses the host name for SNI handling.

Before this change WithURL was being set to the chart reference
instead of the URL. This was a silent bug.

This change sets WithURL using a URL after for the repo is
available when a reference is used instead of a full url.

Signed-off-by: Matt Farina <matt.farina@suse.com>
pull/9871/head
Matt Farina 4 years ago
parent ae8e88e0d9
commit 4e2e4084ed
No known key found for this signature in database
GPG Key ID: 92C44A3D421FF7F9

@ -158,7 +158,6 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
if err != nil {
return nil, errors.Errorf("invalid chart URL format: %s", ref)
}
c.Options = append(c.Options, getter.WithURL(ref))
rf, err := loadRepoConfig(c.RepositoryConfig)
if err != nil {
@ -177,6 +176,8 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
// If there is no special config, return the default HTTP client and
// swallow the error.
if err == ErrNoOwnerRepo {
// Make sure to add the ref URL as the URL for the getter
c.Options = append(c.Options, getter.WithURL(ref))
return u, nil
}
return u, err
@ -215,6 +216,10 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
return u, err
}
// Now that we have the chart repository information we can use that URL
// to set the URL for the getter.
c.Options = append(c.Options, getter.WithURL(rc.URL))
r, err := repo.NewChartRepository(rc, c.Getters)
if err != nil {
return u, err

Loading…
Cancel
Save