From 7c49b7ba69a3e65e5e5a1b9f9ed0a825fbd09aa3 Mon Sep 17 00:00:00 2001 From: "Christopher A. Stelma" Date: Thu, 28 Sep 2017 13:56:58 -0700 Subject: [PATCH] make HELM_HOME portable allow cacheFile to be relative for local index uses a symlink with a relative path on unix final piece of https://github.com/kubernetes/helm/pull/3327 Signed-off-by: Christopher A. Stelma --- cmd/helm/installer/init.go | 6 +++++- cmd/helm/installer/init_unix.go | 7 ++++++- cmd/helm/installer/init_windows.go | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/helm/installer/init.go b/cmd/helm/installer/init.go index 75193d925..52ecdd4e2 100644 --- a/cmd/helm/installer/init.go +++ b/cmd/helm/installer/init.go @@ -96,7 +96,11 @@ func ensureDefaultRepos(home helmpath.Home, out io.Writer, skipRefresh bool, set if err != nil { return err } - lr, err := initLocalRepo(home.LocalRepository(LocalRepositoryIndexFile), home.CacheIndex("local"), home, out, settings, localRepositoryURL) + lif, err := filepath.Rel(home.Cache(), home.CacheIndex("local")) + if err != nil { + return err + } + lr, err := initLocalRepo(home.LocalRepository(LocalRepositoryIndexFile), lif, home, out, settings, localRepositoryURL) if err != nil { return err } diff --git a/cmd/helm/installer/init_unix.go b/cmd/helm/installer/init_unix.go index d7f15a1c2..ab28eab83 100644 --- a/cmd/helm/installer/init_unix.go +++ b/cmd/helm/installer/init_unix.go @@ -20,10 +20,15 @@ package installer // import "k8s.io/helm/cmd/helm/installer" import ( "os" + "path/filepath" "k8s.io/helm/pkg/helm/helmpath" ) func createLink(indexFile, cacheFile string, home helmpath.Home) error { - return os.Symlink(indexFile, cacheFile) + fp, err := filepath.Rel(home.Cache(), indexFile) + if err != nil { + return err + } + return os.Symlink(fp, filepath.Join(home.Cache(), cacheFile)) } diff --git a/cmd/helm/installer/init_windows.go b/cmd/helm/installer/init_windows.go index 48c56e288..7638148ba 100644 --- a/cmd/helm/installer/init_windows.go +++ b/cmd/helm/installer/init_windows.go @@ -20,10 +20,11 @@ package installer // import "k8s.io/helm/cmd/helm/installer" import ( "os" + "path/filepath" "k8s.io/helm/pkg/helm/helmpath" ) func createLink(indexFile, cacheFile string, home helmpath.Home) error { - return os.Link(indexFile, cacheFile) + return os.Link(indexFile, filepath.Join(home.Cache(), cacheFile)) }