mirror of
https://github.com/helm/helm.git
synced 2026-04-21 06:06:56 -04:00
Merge pull request #9824 from sathieu/fix_helm_chart_download_without_trailing_slash
Fix URL with encoded path support for ChartDownloader
This commit is contained in:
commit
792450129f
4 changed files with 19 additions and 0 deletions
|
|
@ -307,6 +307,7 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er
|
|||
}
|
||||
q := repoURL.Query()
|
||||
// We need a trailing slash for ResolveReference to work, but make sure there isn't already one
|
||||
repoURL.RawPath = strings.TrimSuffix(repoURL.RawPath, "/") + "/"
|
||||
repoURL.Path = strings.TrimSuffix(repoURL.Path, "/") + "/"
|
||||
u = repoURL.ResolveReference(u)
|
||||
u.RawQuery = q.Encode()
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ func TestResolveChartRef(t *testing.T) {
|
|||
{name: "reference, testing-relative repo", ref: "testing-relative/bar", expect: "http://example.com/helm/bar-1.2.3.tgz"},
|
||||
{name: "reference, testing-relative-trailing-slash repo", ref: "testing-relative-trailing-slash/foo", expect: "http://example.com/helm/charts/foo-1.2.3.tgz"},
|
||||
{name: "reference, testing-relative-trailing-slash repo", ref: "testing-relative-trailing-slash/bar", expect: "http://example.com/helm/bar-1.2.3.tgz"},
|
||||
{name: "encoded URL", ref: "encoded-url/foobar", expect: "http://example.com/with%2Fslash/charts/foobar-4.2.1.tgz"},
|
||||
{name: "full URL, HTTPS, irrelevant version", ref: "https://example.com/foo-1.2.3.tgz", version: "0.1.0", expect: "https://example.com/foo-1.2.3.tgz", fail: true},
|
||||
{name: "full URL, file", ref: "file:///foo-1.2.3.tgz", fail: true},
|
||||
{name: "invalid", ref: "invalid-1.2.3", fail: true},
|
||||
|
|
|
|||
2
pkg/downloader/testdata/repositories.yaml
vendored
2
pkg/downloader/testdata/repositories.yaml
vendored
|
|
@ -24,3 +24,5 @@ repositories:
|
|||
- name: testing-https-insecureskip-tls-verify
|
||||
url: "https://example-https-insecureskiptlsverify.com"
|
||||
insecure_skip_tls_verify: true
|
||||
- name: encoded-url
|
||||
url: "http://example.com/with%2Fslash"
|
||||
|
|
|
|||
15
pkg/downloader/testdata/repository/encoded-url-index.yaml
vendored
Normal file
15
pkg/downloader/testdata/repository/encoded-url-index.yaml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
entries:
|
||||
foobar:
|
||||
- name: foobar
|
||||
description: Foo Chart With Encoded URL
|
||||
home: https://helm.sh/helm
|
||||
keywords: []
|
||||
maintainers: []
|
||||
sources:
|
||||
- https://github.com/helm/charts
|
||||
urls:
|
||||
- charts/foobar-4.2.1.tgz
|
||||
version: 4.2.1
|
||||
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
|
||||
apiVersion: v2
|
||||
Loading…
Reference in a new issue