Skip to content

Commit

Permalink
Make enableUpdateNotification check a pkg level var
Browse files Browse the repository at this point in the history
  • Loading branch information
r2d4 committed Aug 22, 2016
1 parent 6fc9459 commit 02956e8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
15 changes: 12 additions & 3 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const (
showLibmachineLogs = "show-libmachine-logs"
)

var (
enableUpdateNotification = true
)

var viperWhiteList = []string{
"v",
"alsologtostderr",
Expand All @@ -62,12 +66,17 @@ var RootCmd = &cobra.Command{
}
}

log.SetDebug(viper.Get(showLibmachineLogs))
if !viper.GetBool(showLibmachineLogs) {
shouldShowLibmachineLogs := viper.GetBool(showLibmachineLogs)

log.SetDebug(shouldShowLibmachineLogs)
if !shouldShowLibmachineLogs {
log.SetOutWriter(ioutil.Discard)
log.SetErrWriter(ioutil.Discard)
}
notify.MaybePrintUpdateTextFromGithub(os.Stdout)

if enableUpdateNotification {
notify.MaybePrintUpdateTextFromGithub(os.Stdout)
}
},
}

Expand Down
2 changes: 0 additions & 2 deletions cmd/minikube/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ log_dir: "/etc/hosts"
log-flush-frequency: "3s"
`)

const configName = ".test_minikube_config.yml"

type configTest struct {
Name string
EnvValue string
Expand Down
4 changes: 1 addition & 3 deletions cmd/minikube/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/version"
)

Expand All @@ -32,7 +30,7 @@ var versionCmd = &cobra.Command{
Long: `Print the version of minikube.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// Explicitly disable update checking for the version command
viper.Set(config.WantUpdateNotification, "false")
enableUpdateNotification = false

RootCmd.PersistentPreRun(cmd, args)
},
Expand Down

0 comments on commit 02956e8

Please sign in to comment.