cli: policy check, dont require config or log (#2580)
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
56db4ed0f1
commit
377b854dd8
1 changed files with 7 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/juanfont/headscale/hscontrol/types"
|
"github.com/juanfont/headscale/hscontrol/types"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
@ -25,6 +26,11 @@ func init() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if slices.Contains(os.Args, "policy") && slices.Contains(os.Args, "check") {
|
||||||
|
zerolog.SetGlobalLevel(zerolog.Disabled)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
rootCmd.PersistentFlags().
|
rootCmd.PersistentFlags().
|
||||||
StringVarP(&cfgFile, "config", "c", "", "config file (default is /etc/headscale/config.yaml)")
|
StringVarP(&cfgFile, "config", "c", "", "config file (default is /etc/headscale/config.yaml)")
|
||||||
|
@ -60,7 +66,7 @@ func initConfig() {
|
||||||
|
|
||||||
logFormat := viper.GetString("log.format")
|
logFormat := viper.GetString("log.format")
|
||||||
if logFormat == types.JSONLogFormat {
|
if logFormat == types.JSONLogFormat {
|
||||||
log.Logger = log.Output(os.Stdout)
|
log.Logger = log.Output(os.Stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
disableUpdateCheck := viper.GetBool("disable_check_updates")
|
disableUpdateCheck := viper.GetBool("disable_check_updates")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue