diff --git a/cmd/headscale/cli/utils.go b/cmd/headscale/cli/utils.go index f879f91e..95555e94 100644 --- a/cmd/headscale/cli/utils.go +++ b/cmd/headscale/cli/utils.go @@ -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 +} diff --git a/cmd/headscale/headscale.go b/cmd/headscale/headscale.go index f815001e..6b1a8437 100644 --- a/cmd/headscale/headscale.go +++ b/cmd/headscale/headscale.go @@ -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",