From c8044a4897a017cf6497475454791e0b3c75d327 Mon Sep 17 00:00:00 2001 From: eyalbe4 Date: Sun, 11 Feb 2018 20:16:40 +0200 Subject: [PATCH] Backwards compatibility and doc fix. --- cmd/helm/fetch.go | 4 ++-- docs/chart_repository.md | 4 ++-- pkg/downloader/chart_downloader.go | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cmd/helm/fetch.go b/cmd/helm/fetch.go index 8ccfd8793..069f57eff 100644 --- a/cmd/helm/fetch.go +++ b/cmd/helm/fetch.go @@ -96,8 +96,6 @@ func newFetchCmd(out io.Writer) *cobra.Command { } f := cmd.Flags() - f.StringVar(&fch.username, "username", "", "chart repository username") - f.StringVar(&fch.password, "password", "", "chart repository password") f.BoolVar(&fch.untar, "untar", false, "if set to true, will untar the chart after downloading it") f.StringVar(&fch.untardir, "untardir", ".", "if untar is specified, this flag specifies the name of the directory into which the chart is expanded") f.BoolVar(&fch.verify, "verify", false, "verify the package against its signature") @@ -110,6 +108,8 @@ func newFetchCmd(out io.Writer) *cobra.Command { f.StringVar(&fch.keyFile, "key-file", "", "identify HTTPS client using this SSL key file") f.StringVar(&fch.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") f.BoolVar(&fch.devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.") + f.StringVar(&fch.username, "username", "", "chart repository username") + f.StringVar(&fch.password, "password", "", "chart repository password") return cmd } diff --git a/docs/chart_repository.md b/docs/chart_repository.md index 9d3837bed..5a24249b8 100644 --- a/docs/chart_repository.md +++ b/docs/chart_repository.md @@ -276,9 +276,9 @@ If the charts are backed by HTTP basic authentication, you can also supply the username and password here: ``console -$ helm repo add fantastic-charts https://fantastic-charts.storage.googleapis.com --username my-username--password my-password +$ helm repo add fantastic-charts https://fantastic-charts.storage.googleapis.com --username my-username --password my-password $ helm repo list -fantastic-charts https://username:password@fantastic-charts.storage.googleapis.com +fantastic-charts https://fantastic-charts.storage.googleapis.com ``` **Note:** A repository will not be added if it does not contain a valid diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index 65dbe7bcf..87c80db0c 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -85,7 +85,7 @@ type ChartDownloader struct { // Returns a string path to the location where the file was downloaded and a verification // (if provenance was verified), or an error if something bad happened. func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *provenance.Verification, error) { - u, r, err := c.ResolveChartVersion(ref, version) + u, r, err := c.ResolveChartVersionAndGetRepo(ref, version) if err != nil { return "", nil, err } @@ -156,7 +156,16 @@ func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *proven // * If version is non-empty, this will return the URL for that version // * If version is empty, this will return the URL for the latest version // * If no version can be found, an error is returned -func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, *repo.ChartRepository, error) { +func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, getter.Getter, error) { + u, r, err := c.ResolveChartVersionAndGetRepo(ref, version) + if r != nil { + return u, r.Client, err + } + return u, nil, err +} + +// Same as the ResolveChartVersion method, but returns the chart repositoryy. +func (c *ChartDownloader) ResolveChartVersionAndGetRepo(ref, version string) (*url.URL, *repo.ChartRepository, error) { u, err := url.Parse(ref) if err != nil { return nil, nil, fmt.Errorf("invalid chart URL format: %s", ref)