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 (
"errors"
"fmt"
"github.com/deis/tiller/pkg/client"
"github.com/deis/tiller/pkg/kubectl"
"github.com/spf13/cobra"
)
var tillerImg string
func init() {
initCmd.Flags().StringVarP(&tillerImg, "tiller-image", "i", "", "override tiller image")
RootCommand.AddCommand(initCmd)
}
......@@ -20,6 +25,28 @@ var initCmd = &cobra.Command{
// RunInit initializes local config and installs tiller to Kubernetes Cluster
func RunInit(cmd *cobra.Command, args []string) error {
fmt.Fprintln(stdout, "Init was called.")
return errors.New("NotImplemented")
if len(args) != 0 {
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 (
"testing"
)
func TestRunInit(t *testing.T) {
//TODO: call command and make sure no error is recevied
err := RunInit(initCmd, nil)
if err != nil {
t.Errorf("Expected no error but got one: %s", err)
}
func TestInit(t *testing.T) {
//TODO: call command and make sure no error is returned
//TODO: check local config
}
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