From 10e186cf34b005585fdaaeca8c2ac7c0b861b64e 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 --- cmd/helm/init.go | 2 +- cmd/helm/init_unix.go | 7 ++++++- cmd/helm/init_windows.go | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/helm/init.go b/cmd/helm/init.go index d368945ec..7a94cfc0e 100644 --- a/cmd/helm/init.go +++ b/cmd/helm/init.go @@ -386,7 +386,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, home) + lr, err := initLocalRepo(home.LocalRepository(localRepositoryIndexFile), home.CacheRelativeIndex("local"), out, home) if err != nil { return err } diff --git a/cmd/helm/init_unix.go b/cmd/helm/init_unix.go index 1117dd487..20458a182 100644 --- a/cmd/helm/init_unix.go +++ b/cmd/helm/init_unix.go @@ -20,10 +20,15 @@ package main 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/init_windows.go b/cmd/helm/init_windows.go index be17bccda..597820410 100644 --- a/cmd/helm/init_windows.go +++ b/cmd/helm/init_windows.go @@ -20,10 +20,11 @@ package main 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)) }