From f9c06b1da2c864b40d1a34ef5d076cd19c0ff7c3 Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Mon, 18 Apr 2016 23:36:13 -0600 Subject: [PATCH] feat(init): add cache.txt to $HELM_HOME/local --- cmd/helm/init.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/helm/init.go b/cmd/helm/init.go index 167497962..282d2aaac 100644 --- a/cmd/helm/init.go +++ b/cmd/helm/init.go @@ -20,6 +20,7 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he const repositoriesPath = ".repositories" const cachePath = "cache" const localPath = "local" +const localCacheFilePath = localPath + "/cache.txt" var defaultRepo = map[string]string{"default-name": "default-url"} var tillerImg string @@ -96,12 +97,25 @@ func ensureHome(home string) error { repoPath := repositoriesFile(home) if fi, err := os.Stat(repoPath); err != nil { fmt.Printf("Creating %s \n", repoPath) - if err := ioutil.WriteFile(repoPath, []byte("test-charts: https://www.googleapis.com/storage/v1/b/test-charts/o\n"), 0644); err != nil { + if err := ioutil.WriteFile(repoPath, []byte("local: localhost:8879/charts"), 0644); err != nil { return err } } else if fi.IsDir() { return fmt.Errorf("%s must be a file, not a directory", repoPath) } + + localCacheFile := LocalDirCacheFile(home) + if fi, err := os.Stat(localCacheFile); err != nil { + fmt.Printf("Creating %s \n", localCacheFile) + _, err := os.Create(localCacheFile) + if err != nil { + return err + } + + os.Symlink(localCacheFile, CacheDirectory(home)+"/local-cache.txt") + } else if fi.IsDir() { + return fmt.Errorf("%s must be a file, not a directory.", repoPath) + } return nil } @@ -116,3 +130,7 @@ func repositoriesFile(home string) string { func LocalDirectory(home string) string { return filepath.Join(home, localPath) } + +func LocalDirCacheFile(home string) string { + return filepath.Join(home, localCacheFilePath) +}