Can ctl init with index

This commit is contained in:
2026-03-29 23:55:59 +08:00
parent 03a5e5bedb
commit 5fbc2846a1
5 changed files with 334 additions and 57 deletions

View File

@@ -2,6 +2,7 @@ package root
import (
"flag"
"os"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
@@ -15,6 +16,16 @@ import (
versioncmd "undecided.project/monok8s/pkg/cmd/version"
)
func init() {
klog.InitFlags(nil)
if os.Getenv("DEBUG") != "" {
_ = flag.Set("v", "4") // debug level
} else {
_ = flag.Set("v", "0")
}
}
func NewRootCmd() *cobra.Command {
flags := genericclioptions.NewConfigFlags(true)
@@ -24,7 +35,6 @@ func NewRootCmd() *cobra.Command {
SilenceUsage: true,
SilenceErrors: true,
PersistentPreRun: func(*cobra.Command, []string) {
klog.InitFlags(nil)
_ = flag.Set("logtostderr", "true")
},
}