Commit 499d2457 authored by Ville Aikas's avatar Ville Aikas

Merge pull request #716 from vaikas-google/master

Offset where the directories and files go from $HELM_HOME to $HELM_HOME/repository
parents dde6bb37 d636fb1e
...@@ -77,7 +77,7 @@ func installTiller() error { ...@@ -77,7 +77,7 @@ func installTiller() error {
// //
// If $HELM_HOME does not exist, this function will create it. // If $HELM_HOME does not exist, this function will create it.
func ensureHome() error { func ensureHome() error {
configDirectories := []string{homePath(), cacheDirectory(), localRepoDirectory()} configDirectories := []string{homePath(), repositoryDirectory(), cacheDirectory(), localRepoDirectory()}
for _, p := range configDirectories { for _, p := range configDirectories {
if fi, err := os.Stat(p); err != nil { if fi, err := os.Stat(p); err != nil {
......
...@@ -13,7 +13,7 @@ func TestEnsureHome(t *testing.T) { ...@@ -13,7 +13,7 @@ func TestEnsureHome(t *testing.T) {
t.Errorf("%s", err) t.Errorf("%s", err)
} }
expectedDirs := []string{homePath(), cacheDirectory(), localRepoDirectory()} expectedDirs := []string{homePath(), repositoryDirectory(), cacheDirectory(), localRepoDirectory()}
for _, dir := range expectedDirs { for _, dir := range expectedDirs {
if fi, err := os.Stat(dir); err != nil { if fi, err := os.Stat(dir); err != nil {
t.Errorf("%s", err) t.Errorf("%s", err)
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
) )
const ( const (
repositoryDir string = "repository"
repositoriesFilePath string = "repositories.yaml" repositoriesFilePath string = "repositories.yaml"
cachePath string = "cache" cachePath string = "cache"
localRepoPath string = "local" localRepoPath string = "local"
...@@ -16,16 +17,21 @@ func homePath() string { ...@@ -16,16 +17,21 @@ func homePath() string {
return os.ExpandEnv(helmHome) return os.ExpandEnv(helmHome)
} }
// All other directories go under the $HELM_HOME/repository.
func repositoryDirectory() string {
return homePath() + "/" + repositoryDir
}
func cacheDirectory(paths ...string) string { func cacheDirectory(paths ...string) string {
fragments := append([]string{homePath(), cachePath}, paths...) fragments := append([]string{repositoryDirectory(), cachePath}, paths...)
return filepath.Join(fragments...) return filepath.Join(fragments...)
} }
func localRepoDirectory(paths ...string) string { func localRepoDirectory(paths ...string) string {
fragments := append([]string{homePath(), localRepoPath}, paths...) fragments := append([]string{repositoryDirectory(), localRepoPath}, paths...)
return filepath.Join(fragments...) return filepath.Join(fragments...)
} }
func repositoriesFile() string { func repositoriesFile() string {
return filepath.Join(homePath(), repositoriesFilePath) return filepath.Join(repositoryDirectory(), repositoriesFilePath)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment