From e23d88be717fc3e035146d23b9d68b58324d2c8d Mon Sep 17 00:00:00 2001 From: Matt Rickard Date: Wed, 12 Oct 2016 10:40:14 -0700 Subject: [PATCH] Set default log_dir to ~/.minikube/logs A hack around specifying the default log dir for glog. Since we can't set it without modifying the flag, we check if the flag has been changed. If not, we set it to our default value. --- cmd/minikube/cmd/root.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index f536776f42..ca172109e3 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -42,6 +42,7 @@ var dirs = [...]string{ constants.MakeMiniPath("cache", "localkube"), constants.MakeMiniPath("config"), constants.MakeMiniPath("addons"), + constants.MakeMiniPath("logs"), } const ( @@ -106,6 +107,7 @@ func setFlagsUsingViper() { // Viper will give precedence first to calls to the Set command, // then to values from the config.yml a.Value.Set(viper.GetString(a.Name)) + a.Changed = true } } @@ -114,6 +116,10 @@ func init() { RootCmd.AddCommand(configCmd.ConfigCmd) RootCmd.AddCommand(configCmd.AddonsCmd) pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) + logDir := pflag.Lookup("log_dir") + if !logDir.Changed { + logDir.Value.Set(constants.MakeMiniPath("logs")) + } viper.BindPFlags(RootCmd.PersistentFlags()) cobra.OnInitialize(initConfig) }