From 9e45ac117d4da5715e4315805d59732a25b27791 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 22 Jun 2016 13:55:07 -0600 Subject: [PATCH] feat(helm): install directly from repo A helm install command will try to load a chart from a local file first. But if a local file is not found, it will try to fetch a file from a matching repo request. The file will be downloaded to the client, and then sent to Tiller for installation. --- cmd/helm/fetch.go | 5 +++++ cmd/helm/install.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/cmd/helm/fetch.go b/cmd/helm/fetch.go index 2d9f45a13..6696a98f5 100644 --- a/cmd/helm/fetch.go +++ b/cmd/helm/fetch.go @@ -39,6 +39,11 @@ func fetch(cmd *cobra.Command, args []string) error { if filepath.Ext(pname) != ".tgz" { pname += ".tgz" } + return fetchChart(pname) + +} + +func fetchChart(pname string) error { f, err := repo.LoadRepositoriesFile(repositoriesFile()) if err != nil { diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 3b1877ff9..bf20f0b79 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -117,5 +117,19 @@ func locateChartPath(name string) (string, error) { if _, err := os.Stat(crepo); err == nil { return filepath.Abs(crepo) } + + // Try fetching the chart from a remote repo into a tmpdir + if filepath.Ext(name) != ".tgz" { + name += ".tgz" + } + if err := fetchChart(name); err == nil { + lname, err := filepath.Abs(filepath.Base(name)) + if err != nil { + return lname, err + } + fmt.Printf("Fetched %s to %s\n", name, lname) + return lname, nil + } + return name, fmt.Errorf("file %q not found", name) }