Unified error handling when calling newRootCmd.

Signed-off-by: yxxhero <aiopsclub@163.com>
pull/8770/head
yxxhero 5 years ago
parent 467bd49bb0
commit 337ed48fb2

@ -75,8 +75,7 @@ func main() {
actionConfig := new(action.Configuration) actionConfig := new(action.Configuration)
cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
if err != nil { if err != nil {
debug("%+v", err) log.Fatal(err)
os.Exit(1)
} }
// run when each command's execute method is called // run when each command's execute method is called

@ -20,7 +20,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"log"
"strings" "strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -116,7 +115,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
}) })
if err != nil { if err != nil {
log.Fatal(err) return nil, err
} }
// Setup shell completion for the kube-context flag // Setup shell completion for the kube-context flag
@ -142,7 +141,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
}) })
if err != nil { if err != nil {
log.Fatal(err) return nil, err
} }
// We can safely ignore any errors that flags.Parse encounters since // We can safely ignore any errors that flags.Parse encounters since

Loading…
Cancel
Save