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.
pull/681/head
Matt Rickard 2016-10-12 10:40:14 -07:00
parent adc23d6a30
commit e23d88be71
1 changed files with 6 additions and 0 deletions

View File

@ -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)
}