Commit 306aca6a authored by Michelle Noorali's avatar Michelle Noorali

feat(init): add init logic

+ -i flag to override tiller image
parent 72acb82e
...@@ -4,10 +4,15 @@ import ( ...@@ -4,10 +4,15 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/deis/tiller/pkg/client"
"github.com/deis/tiller/pkg/kubectl"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var tillerImg string
func init() { func init() {
initCmd.Flags().StringVarP(&tillerImg, "tiller-image", "i", "", "override tiller image")
RootCommand.AddCommand(initCmd) RootCommand.AddCommand(initCmd)
} }
...@@ -20,6 +25,28 @@ var initCmd = &cobra.Command{ ...@@ -20,6 +25,28 @@ var initCmd = &cobra.Command{
// RunInit initializes local config and installs tiller to Kubernetes Cluster // RunInit initializes local config and installs tiller to Kubernetes Cluster
func RunInit(cmd *cobra.Command, args []string) error { func RunInit(cmd *cobra.Command, args []string) error {
fmt.Fprintln(stdout, "Init was called.") if len(args) != 0 {
return errors.New("NotImplemented") return errors.New("This command does not accept arguments. \n")
}
// TODO: take value of global flag kubectl and pass that in
runner := buildKubectlRunner("")
i := client.NewInstaller()
i.Tiller["Image"] = tillerImg
out, err := i.Install(runner)
if err != nil {
return fmt.Errorf("error installing %s %s", string(out), err)
}
fmt.Printf("Tiller (the helm server side component) has been installed into your Kubernetes Cluster.\n")
return nil
}
func buildKubectlRunner(kubectlPath string) kubectl.Runner {
if kubectlPath != "" {
kubectl.Path = kubectlPath
}
return &kubectl.RealRunner{}
} }
...@@ -4,11 +4,7 @@ import ( ...@@ -4,11 +4,7 @@ import (
"testing" "testing"
) )
func TestRunInit(t *testing.T) { func TestInit(t *testing.T) {
//TODO: call command and make sure no error is returned
//TODO: call command and make sure no error is recevied //TODO: check local config
err := RunInit(initCmd, nil)
if err != nil {
t.Errorf("Expected no error but got one: %s", err)
}
} }
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