Make CLI functions return error instead of fatal out (#1379)
Before this PR, CLI functions fatal out when encountering error instead of returning it. Such behavior makes it hard to reuse the functions nor writing unit tests. This PR aims to make functions return errors instead of error out.
This commit is contained in:
@@ -25,8 +25,7 @@ import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/log"
|
||||
"github.com/fission/fission/pkg/fission-cli/consolemsg"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -36,8 +35,12 @@ type UpdateSubCommand struct {
|
||||
}
|
||||
|
||||
func Update(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: cmd.GetServer(flags),
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
}
|
||||
@@ -70,7 +73,7 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
|
||||
functionList := flags.StringSlice("function")
|
||||
err := util.CheckFunctionExistence(opts.client, functionList, triggerNamespace)
|
||||
if err != nil {
|
||||
log.Warn(err.Error())
|
||||
consolemsg.Warn(err.Error())
|
||||
}
|
||||
|
||||
var functionWeightsList []int
|
||||
@@ -93,7 +96,7 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
|
||||
|
||||
if flags.IsSet("host") {
|
||||
ht.Spec.Host = flags.String("host")
|
||||
log.Warn(fmt.Sprintf("--host is now marked as deprecated, see 'help' for details"))
|
||||
consolemsg.Warn(fmt.Sprintf("--host is now marked as deprecated, see 'help' for details"))
|
||||
}
|
||||
|
||||
if flags.IsSet("ingressrule") || flags.IsSet("ingressannotation") || flags.IsSet("ingresstls") {
|
||||
|
||||
Reference in New Issue
Block a user