bug: karmadactl's os.Exit will not wait for the defer function

Signed-off-by: kerthcet <kerthcet@gmail.com>
This commit is contained in:
kerthcet 2022-01-25 19:14:21 +08:00
parent 85554ff187
commit 29020d6ca6
1 changed files with 9 additions and 1 deletions

View File

@ -9,10 +9,18 @@ import (
)
func main() {
if err := runKarmadaCtlCmd(); err != nil {
os.Exit(1)
}
}
func runKarmadaCtlCmd() error {
logs.InitLogs()
defer logs.FlushLogs()
if err := karmadactl.NewKarmadaCtlCommand(os.Stdout, "karmadactl", "karmadactl").Execute(); err != nil {
os.Exit(1)
return err
}
return nil
}