Commit 95ffc1b7 authored by CHRISTOPHER PIKE's avatar CHRISTOPHER PIKE

Merge branch 'master' into develop

parents 793cb118 fdc42691
Pipeline #76518 failed with stages
in 26 seconds
......@@ -16,16 +16,16 @@ package cmd
import (
"fmt"
"os"
"os/exec"
"strconv"
"strings"
"time"
"github.com/spf13/viper"
"git.psu.edu/k8s/devtool/environment"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// startCmd represents the start command
......@@ -43,6 +43,11 @@ var startCmd = &cobra.Command{
},
}
const (
helmVersionThreeTag = "Version"
helmVersionTwoTag = "SemVer"
)
func init() {
rootCmd.AddCommand(startCmd)
......@@ -86,7 +91,10 @@ func start(memory, cpu, k8sVersion string) {
return
}
environment.RunRequired(true, "helm", "init", "--client-only")
if helmVersion2() {
color.Yellow("Detected helm version 2, initting as client-only")
environment.RunRequired(true, "helm", "init", "--client-only")
}
environment.RunRequired(true, "helm", "repo", "add", "cm", "https://cm.qa.k8s.psu.edu")
color.Blue("Setting up Minikube environment.")
......@@ -105,12 +113,40 @@ func start(memory, cpu, k8sVersion string) {
fixKubectlContext()
checkInstallTiller()
if helmVersion2() {
checkInstallTiller()
}
checkIfSwaggerUiInstalled()
}
func helmVersion2() bool {
cmd := exec.Command("helm", "version", "-c")
bytes, err := cmd.Output()
if err != nil {
fmt.Printf("Failed to exec, helm installed?: %v\n\n", err)
os.Exit(-1)
}
ss := strings.FieldsFunc(string(bytes), func(r rune) bool {
if r == '{' {
return true
}
return false
})
keyValues := strings.Split(ss[1], ":")
if keyValues[0] == helmVersionTwoTag {
return true
}
return false
}
func checkLocalSetup() bool {
var prereqsInstalled = true
err := checkInstalled("kubectl")
......@@ -222,6 +258,10 @@ func checkIfSwaggerUiInstalled() {
}
if !swaggerInstalled {
environment.RunRequired(true, "helm", "install", "--name", "swagger-ui", "cm/swagger-ui")
if helmVersion2() {
environment.RunRequired(true, "helm", "install", "--name", "swagger-ui", "cm/swagger-ui")
} else {
environment.RunRequired(true, "helm", "install", "swagger-ui", "cm/swagger-ui")
}
}
}
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