diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index 785a2db36b..47a91848c4 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -107,7 +107,9 @@ func Execute() { profile := "" for i, a := range os.Args { if a == "--context" { - profile = fmt.Sprintf("--profile=%s", os.Args[i+1]) + if len(os.Args) > i+1 { + profile = fmt.Sprintf("--profile=%s", os.Args[i+1]) + } break } else if strings.HasPrefix(a, "--context=") { context := strings.Split(a, "=")[1] diff --git a/hack/benchmark/cpu_usage/auto_pause/chart.go b/hack/benchmark/cpu_usage/auto_pause/chart.go index 53ebf9b8bc..56b97796ed 100644 --- a/hack/benchmark/cpu_usage/auto_pause/chart.go +++ b/hack/benchmark/cpu_usage/auto_pause/chart.go @@ -54,10 +54,10 @@ func main() { func execute() error { // sessionID is generated and used at cpu usage benchmark - sessionID := os.Args[1] - if len(sessionID) == 0 { + if len(os.Args) <= 1 || len(os.Args[1]) == 0 { return errors.New("Please identify sessionID") } + sessionID := os.Args[1] // Create plot instance p := plot.New() diff --git a/hack/benchmark/cpu_usage/idle_only/chart.go b/hack/benchmark/cpu_usage/idle_only/chart.go index e06138b322..c7058894eb 100644 --- a/hack/benchmark/cpu_usage/idle_only/chart.go +++ b/hack/benchmark/cpu_usage/idle_only/chart.go @@ -53,10 +53,10 @@ func main() { func execute() error { // sessionID is generated and used at cpu usage benchmark - sessionID := os.Args[1] - if len(sessionID) == 0 { + if len(os.Args) <= 1 || len(os.Args[1]) == 0 { return errors.New("Please identify sessionID") } + sessionID := os.Args[1] // Create plot instance p := plot.New()