Fix #2937 - helm always appends /index.yaml at the end of URL (#2988)

* Closes #2937
Added required dependency to run make test in developer's guide

* Fixed base URL appending when chart address is not absolute

* Removed requirement from developers.md

* Fixed unnecessary line breaks

* Added tests for query string repo

* Returning URL along with error
pull/3016/head
Michal Cwienczek 8 years ago committed by Matt Butcher
parent d7a81c99e1
commit dad8c6f644

@ -217,7 +217,12 @@ 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() {
u, err = url.Parse(rc.URL + "/" + u.Path)
path := u.Path
u, err = url.Parse(rc.URL)
if err != nil {
return u, r.Client, err
}
u.Path = u.Path + path
return u, r.Client, err
}

@ -43,6 +43,7 @@ func TestResolveChartRef(t *testing.T) {
{name: "reference, testing repo", ref: "testing/alpine", expect: "http://example.com/alpine-1.2.3.tgz"},
{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: "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,16 @@
apiVersion: v1
entries:
alpine:
- name: alpine
urls:
- alpine-1.2.3.tgz
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
home: https://k8s.io/helm
sources:
- https://github.com/kubernetes/helm
version: 1.2.3
description: Deploy a basic Alpine Linux pod
keywords: []
maintainers: []
engine: ""
icon: ""

@ -10,3 +10,5 @@ repositories:
url: "http://example.com/charts"
- name: malformed
url: "http://dl.example.com"
- name: testing-querystring
url: "http://example.com?key=value"

@ -110,8 +110,13 @@ func (r *ChartRepository) Load() error {
// is for pre-2.2.0 repo files.
func (r *ChartRepository) DownloadIndexFile(cachePath string) error {
var indexURL string
parsedURL, err := url.Parse(r.Config.URL)
if err != nil {
return err
}
parsedURL.Path = strings.TrimSuffix(parsedURL.Path, "/") + "/index.yaml"
indexURL = strings.TrimSuffix(r.Config.URL, "/") + "/index.yaml"
indexURL = parsedURL.String()
resp, err := r.Client.Get(indexURL)
if err != nil {
return err

Loading…
Cancel
Save