in pkg/cmd/root.go [27:66]
func NewRootCmd() *cobra.Command {
flushLogs := mlog.Setup()
cmd := &cobra.Command{
Use: rootName,
Short: rootShortDescription,
Long: rootLongDescription,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// default to info instead of warning because existing info logs expect to always be printed
logLevel := mlog.LevelInfo
if debug {
logLevel = mlog.LevelAll
}
// inputs are essentially static so this should never error
return mlog.ValidateAndSetLogLevelAndFormatGlobally(
context.Background(), // context is unused with mlog.FormatCLI
mlog.LogSpec{
Level: logLevel,
Format: mlog.FormatCLI,
},
)
},
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Usage()
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
flushLogs()
},
}
p := cmd.PersistentFlags()
p.BoolVar(&debug, "debug", false, "Enable debug logging")
cmd.AddCommand(version.NewVersionCmd())
cmd.AddCommand(serviceaccount.NewServiceAccountCmd())
cmd.AddCommand(jwks.NewJWKSCmd())
cmd.AddCommand(podidentity.NewPodIdentityCmd())
return cmd
}