mirror of https://github.com/helm/helm
Merge pull request #28 from michelleN/helm-init
feat(init): add local config step to initpull/613/head
commit
d54c351afb
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var longHomeHelp = `
|
||||
This command displays the location of HELM_HOME. This is where
|
||||
any helm configuration files live.
|
||||
`
|
||||
|
||||
var homeCommand = &cobra.Command{
|
||||
Use: "home",
|
||||
Short: "Displays the location of HELM_HOME",
|
||||
Long: longHomeHelp,
|
||||
Run: Home,
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCommand.AddCommand(homeCommand)
|
||||
}
|
||||
|
||||
func Home(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("helm home was called")
|
||||
}
|
@ -1,10 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
//TODO: call command and make sure no error is returned
|
||||
//TODO: check local config
|
||||
func TestEnsureHome(t *testing.T) {
|
||||
home := CreateTmpHome()
|
||||
if err := EnsureHome(home); err != nil {
|
||||
t.Errorf("%s", err)
|
||||
}
|
||||
|
||||
dirs := []string{home, CacheDirectory(home)}
|
||||
for _, dir := range dirs {
|
||||
if fi, err := os.Stat(dir); err != nil {
|
||||
t.Errorf("%s", err)
|
||||
} else if !fi.IsDir() {
|
||||
t.Errorf("%s is not a directory", fi)
|
||||
}
|
||||
}
|
||||
|
||||
if fi, err := os.Stat(RepositoriesFile(home)); err != nil {
|
||||
t.Errorf("%s", err)
|
||||
} else if fi.IsDir() {
|
||||
t.Errorf("%s should not be a directory", fi)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func CreateTmpHome() string {
|
||||
tmpHome, _ := ioutil.TempDir("", "helm_home")
|
||||
defer os.Remove(tmpHome)
|
||||
return tmpHome
|
||||
}
|
||||
|
Loading…
Reference in new issue