Skip to content

Commit

Permalink
fix(kumactl) Fix error handling
Browse files Browse the repository at this point in the history
* Properly early-return error to calling function
* Send warnings to stderr

Signed-off-by: Paul Parkanzky <paul.parkanzky@konghq.com>
  • Loading branch information
Paul Parkanzky committed Apr 26, 2021
1 parent 2e166f9 commit a5c8ced
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/kumactl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ func NewRootCmd(root *kumactl_cmd.RootContext) *cobra.Command {
}
}

retval := root.LoadConfig()
err = root.LoadConfig()
if err != nil {
return err
}

client, err := root.CurrentApiClient()
if err != nil {
kumactlLog.Error(err, "Unable to get index client")
Expand All @@ -67,9 +71,9 @@ func NewRootCmd(root *kumactl_cmd.RootContext) *cobra.Command {
}

if kumaBuildVersion != nil && (kumaBuildVersion.Version != kuma_version.Build.Version || kumaBuildVersion.Tagline != kuma_version.Product) {
cmd.Println("WARNING: You are using kumactl version " + kuma_version.Build.Version + " for " + kuma_version.Product + ", but the server returned version: " + kumaBuildVersion.Tagline + " " + kumaBuildVersion.Version)
cmd.PrintErr("WARNING: You are using kumactl version " + kuma_version.Build.Version + " for " + kuma_version.Product + ", but the server returned version: " + kumaBuildVersion.Tagline + " " + kumaBuildVersion.Version + "\n")
}
return retval
return nil
},
}
// root flags
Expand Down

0 comments on commit a5c8ced

Please sign in to comment.