From 81e09ff14c0b45c1c9cbe9a72a0a61156d5a7981 Mon Sep 17 00:00:00 2001 From: Ryan Payton Date: Thu, 7 Sep 2017 12:57:23 -0700 Subject: [PATCH 1/2] updating DownloadIndexFile function call to pass in HELM_HOME --- cmd/helm/init.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/helm/init.go b/cmd/helm/init.go index c8753874f..c0a7f6fcf 100644 --- a/cmd/helm/init.go +++ b/cmd/helm/init.go @@ -362,7 +362,7 @@ func ensureDefaultRepos(home helmpath.Home, out io.Writer, skipRefresh bool) err if fi, err := os.Stat(repoFile); err != nil { fmt.Fprintf(out, "Creating %s \n", repoFile) f := repo.NewRepoFile() - sr, err := initStableRepo(home.CacheIndex(stableRepository), out, skipRefresh) + sr, err := initStableRepo(home.CacheIndex(stableRepository), out, skipRefresh, home) if err != nil { return err } @@ -381,7 +381,7 @@ func ensureDefaultRepos(home helmpath.Home, out io.Writer, skipRefresh bool) err return nil } -func initStableRepo(cacheFile string, out io.Writer, skipRefresh bool) (*repo.Entry, error) { +func initStableRepo(cacheFile string, out io.Writer, skipRefresh bool, home helmpath.Home) (*repo.Entry, error) { fmt.Fprintf(out, "Adding %s repo with URL: %s \n", stableRepository, stableRepositoryURL) c := repo.Entry{ Name: stableRepository, From dc7e465705c6b5a7f387b4833a86e5459bd6a8cd Mon Sep 17 00:00:00 2001 From: "Christopher A. Stelma" Date: Thu, 1 Mar 2018 14:52:11 -0800 Subject: [PATCH 2/2] pass home down through createLink --- cmd/helm/init.go | 8 +++++--- cmd/helm/init_unix.go | 6 ++++-- cmd/helm/init_windows.go | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/helm/init.go b/cmd/helm/init.go index c0a7f6fcf..9fbd5fc89 100644 --- a/cmd/helm/init.go +++ b/cmd/helm/init.go @@ -366,7 +366,7 @@ func ensureDefaultRepos(home helmpath.Home, out io.Writer, skipRefresh bool) err if err != nil { return err } - lr, err := initLocalRepo(home.LocalRepository(localRepositoryIndexFile), home.CacheIndex("local"), out) + lr, err := initLocalRepo(home.LocalRepository(localRepositoryIndexFile), home.CacheIndex("local"), out, home) if err != nil { return err } @@ -406,7 +406,7 @@ func initStableRepo(cacheFile string, out io.Writer, skipRefresh bool, home helm return &c, nil } -func initLocalRepo(indexFile, cacheFile string, out io.Writer) (*repo.Entry, error) { +func initLocalRepo(indexFile, cacheFile string, out io.Writer, home helmpath.Home) (*repo.Entry, error) { if fi, err := os.Stat(indexFile); err != nil { fmt.Fprintf(out, "Adding %s repo with URL: %s \n", localRepository, localRepositoryURL) i := repo.NewIndexFile() @@ -415,7 +415,9 @@ func initLocalRepo(indexFile, cacheFile string, out io.Writer) (*repo.Entry, err } //TODO: take this out and replace with helm update functionality - createLink(indexFile, cacheFile) + if err := createLink(indexFile, cacheFile, home); err != nil { + return nil, err + } } else if fi.IsDir() { return nil, fmt.Errorf("%s must be a file, not a directory", indexFile) } diff --git a/cmd/helm/init_unix.go b/cmd/helm/init_unix.go index ff6260434..1117dd487 100644 --- a/cmd/helm/init_unix.go +++ b/cmd/helm/init_unix.go @@ -20,8 +20,10 @@ package main import ( "os" + + "k8s.io/helm/pkg/helm/helmpath" ) -func createLink(indexFile, cacheFile string) { - os.Symlink(indexFile, cacheFile) +func createLink(indexFile, cacheFile string, home helmpath.Home) error { + return os.Symlink(indexFile, cacheFile) } diff --git a/cmd/helm/init_windows.go b/cmd/helm/init_windows.go index 73ae6c6de..be17bccda 100644 --- a/cmd/helm/init_windows.go +++ b/cmd/helm/init_windows.go @@ -20,8 +20,10 @@ package main import ( "os" + + "k8s.io/helm/pkg/helm/helmpath" ) -func createLink(indexFile, cacheFile string) { - os.Link(indexFile, cacheFile) +func createLink(indexFile, cacheFile string, home helmpath.Home) error { + return os.Link(indexFile, cacheFile) }