hook up mkcmp command to code to time 'minikube start'

pull/5678/head
Priya Wadhwa 2019-10-21 11:10:49 -07:00
parent 4a57b8864d
commit 5242dcb0b8
1 changed files with 14 additions and 4 deletions

View File

@ -17,20 +17,30 @@ limitations under the License.
package cmd package cmd
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"k8s.io/minikube/pkg/minikube/performance"
) )
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "mkcmp [path to first binary] [path to second binary]", Use: "mkcmp [path to first binary] [path to second binary]",
Short: "mkcmp is used to compare performance of two minikube binaries", Short: "mkcmp is used to compare performance of two minikube binaries",
SilenceUsage: true,
SilenceErrors: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return validateArgs(args) return validateArgs(args)
}, },
Run: func(cmd *cobra.Command, args []string) {}, RunE: func(cmd *cobra.Command, args []string) error {
binaries, err := performance.Binaries(args)
if err != nil {
return err
}
return performance.CompareMinikubeStart(context.Background(), binaries)
},
} }
func validateArgs(args []string) error { func validateArgs(args []string) error {
@ -43,7 +53,7 @@ func validateArgs(args []string) error {
// Execute runs the mkcmp command // Execute runs the mkcmp command
func Execute() { func Execute() {
if err := rootCmd.Execute(); err != nil { if err := rootCmd.Execute(); err != nil {
fmt.Println(err) fmt.Println("Error:", err)
os.Exit(1) os.Exit(1)
} }
} }