From d9f3bdfa67dc84d9e7f26f070ae9a01c83980c8d Mon Sep 17 00:00:00 2001 From: "Christopher A. Stelma" Date: Thu, 28 Sep 2017 13:56:58 -0700 Subject: [PATCH 1/2] fix remaining known local/relative paths --- cmd/helm/init.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/helm/init.go b/cmd/helm/init.go index bafe5231f..35aa6c4b2 100644 --- a/cmd/helm/init.go +++ b/cmd/helm/init.go @@ -21,6 +21,7 @@ import ( "fmt" "io" "os" + "path/filepath" "github.com/spf13/cobra" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -330,9 +331,7 @@ func initStableRepo(cacheFile string, out io.Writer, skipRefresh bool, home helm return &c, nil } - // In this case, the cacheFile is always absolute. So passing empty string - // is safe. - if err := r.DownloadIndexFile(home.String()); err != nil { + if err := r.DownloadIndexFile(home.Cache()); err != nil { return nil, fmt.Errorf("Looks like %q is not a valid chart repository or cannot be reached: %s", stableRepositoryURL, err.Error()) } @@ -348,7 +347,12 @@ func initLocalRepo(indexFile, cacheFile string, out io.Writer) (*repo.Entry, err } //TODO: take this out and replace with helm update functionality - os.Symlink(indexFile, cacheFile) + fp, err := filepath.Rel(indexFile, cacheFile) + if err != nil { + return nil, err + } + pth := filepath.Join(fp) + os.Symlink(pth, cacheFile) } else if fi.IsDir() { return nil, fmt.Errorf("%s must be a file, not a directory", indexFile) } From 7eb76611606b32019fa50c07d9363f213c3ef7ec Mon Sep 17 00:00:00 2001 From: "Christopher A. Stelma" Date: Thu, 28 Sep 2017 16:40:55 -0700 Subject: [PATCH 2/2] fix path relativity --- cmd/helm/init.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/helm/init.go b/cmd/helm/init.go index 35aa6c4b2..a14d945a2 100644 --- a/cmd/helm/init.go +++ b/cmd/helm/init.go @@ -300,7 +300,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 } @@ -338,7 +338,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() @@ -347,11 +347,11 @@ func initLocalRepo(indexFile, cacheFile string, out io.Writer) (*repo.Entry, err } //TODO: take this out and replace with helm update functionality - fp, err := filepath.Rel(indexFile, cacheFile) + fp, err := filepath.Rel(cacheFile, indexFile) if err != nil { return nil, err } - pth := filepath.Join(fp) + pth := home.Path(fp) os.Symlink(pth, cacheFile) } else if fi.IsDir() { return nil, fmt.Errorf("%s must be a file, not a directory", indexFile)