Merge pull request #3065 from cjauvin/fix-for-relative-chart-path-support

Fix for relative chart path support in index.yaml
pull/2950/merge
Matthew Fisher 7 years ago committed by GitHub
commit 93e1c765df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -217,12 +217,15 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, ge
// If the URL is relative (no scheme), prepend the chart repo's base URL
if !u.IsAbs() {
path := u.Path
u, err = url.Parse(rc.URL)
repoURL, err := url.Parse(rc.URL)
if err != nil {
return u, r.Client, err
return repoURL, r.Client, err
}
u.Path = u.Path + path
q := repoURL.Query()
// We need a trailing slash for ResolveReference to work, but make sure there isn't already one
repoURL.Path = strings.TrimSuffix(repoURL.Path, "/") + "/"
u = repoURL.ResolveReference(u)
u.RawQuery = q.Encode()
return u, r.Client, err
}

@ -44,6 +44,10 @@ func TestResolveChartRef(t *testing.T) {
{name: "reference, version, testing repo", ref: "testing/alpine", version: "0.2.0", expect: "http://example.com/alpine-0.2.0.tgz"},
{name: "reference, version, malformed repo", ref: "malformed/alpine", version: "1.2.3", expect: "http://dl.example.com/alpine-1.2.3.tgz"},
{name: "reference, querystring repo", ref: "testing-querystring/alpine", expect: "http://example.com/alpine-1.2.3.tgz?key=value"},
{name: "reference, testing-relative repo", ref: "testing-relative/foo", expect: "http://example.com/helm/charts/foo-1.2.3.tgz"},
{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: "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},

@ -0,0 +1,28 @@
apiVersion: v1
entries:
foo:
- name: foo
description: Foo Chart With Relative Path
engine: gotpl
home: https://k8s.io/helm
keywords: []
maintainers: []
sources:
- https://github.com/kubernetes/charts
urls:
- charts/foo-1.2.3.tgz
version: 1.2.3
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
bar:
- name: bar
description: Bar Chart With Relative Path
engine: gotpl
home: https://k8s.io/helm
keywords: []
maintainers: []
sources:
- https://github.com/kubernetes/charts
urls:
- bar-1.2.3.tgz
version: 1.2.3
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d

@ -0,0 +1,28 @@
apiVersion: v1
entries:
foo:
- name: foo
description: Foo Chart With Relative Path
engine: gotpl
home: https://k8s.io/helm
keywords: []
maintainers: []
sources:
- https://github.com/kubernetes/charts
urls:
- charts/foo-1.2.3.tgz
version: 1.2.3
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
bar:
- name: bar
description: Bar Chart With Relative Path
engine: gotpl
home: https://k8s.io/helm
keywords: []
maintainers: []
sources:
- https://github.com/kubernetes/charts
urls:
- bar-1.2.3.tgz
version: 1.2.3
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d

@ -11,4 +11,8 @@ repositories:
- name: malformed
url: "http://dl.example.com"
- name: testing-querystring
url: "http://example.com?key=value"
url: "http://example.com?key=value"
- name: testing-relative
url: "http://example.com/helm"
- name: testing-relative-trailing-slash
url: "http://example.com/helm/"
Loading…
Cancel
Save