Skip to content

Commit

Permalink
Merge pull request #156 from juanfont/disable-version-check-on-json
Browse files Browse the repository at this point in the history
Disable version checker when using JSON output
  • Loading branch information
juanfont authored Oct 13, 2021
2 parents 70ae18c + 5f0f370 commit 809a5b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmd/headscale/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,12 @@ func JsonOutput(result interface{}, errResult error, outputFormat string) {
}
fmt.Println(string(j))
}

func HasJsonOutputFlag() bool {
for _, arg := range os.Args {
if arg == "json" || arg == "json-line" {
return true
}
}
return false
}
3 changes: 2 additions & 1 deletion cmd/headscale/headscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func main() {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}

if !viper.GetBool("disable_check_updates") {
jsonOutput := cli.HasJsonOutputFlag()
if !viper.GetBool("disable_check_updates") && !jsonOutput {
if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && cli.Version != "dev" {
githubTag := &latest.GithubTag{
Owner: "juanfont",
Expand Down

0 comments on commit 809a5b8

Please sign in to comment.