Merge pull request #2512 from technosophos/fix/2510-missing-url-prefix

fix(helm): prepend repo URL to packages missing scheme
pull/2541/head
Matt Butcher 7 years ago committed by GitHub
commit 3647e60786

@ -10,6 +10,8 @@ send us a pull request.
**Q: Why do I get a `unsupported protocol scheme ""` error when trying to fetch a chart from my custom repo?**
A: This is likely caused by you creating your chart repo index without specifying the `--url` flag.
A: (Helm < 2.5.0) This is likely caused by you creating your chart repo index without specifying the `--url` flag.
Try recreating your `index.yaml` file with a command like `heml repo index --url http://my-repo/charts .`,
and then re-uploading it to your custom charts repo.
This behavior was changed in Helm 2.5.0.

@ -215,6 +215,12 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, ge
return u, r.Client, fmt.Errorf("invalid chart URL format: %s", ref)
}
// 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)
return u, r.Client, err
}
return u, r.Client, nil
}

@ -42,6 +42,7 @@ func TestResolveChartRef(t *testing.T) {
{name: "full URL, with authentication", ref: "http://username:password@example.com/foo-1.2.3.tgz", expect: "http://username:password@example.com/foo-1.2.3.tgz"},
{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: "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: ""

@ -8,3 +8,5 @@ repositories:
url: "http://username:password@example.com"
- name: kubernetes-charts
url: "http://example.com/charts"
- name: malformed
url: "http://dl.example.com"

Loading…
Cancel
Save