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:
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
"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/util"
|
||||
)
|
||||
|
||||
type ListSubCommand struct {
|
||||
@@ -34,8 +34,12 @@ type ListSubCommand struct {
|
||||
}
|
||||
|
||||
func List(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: cmd.GetServer(flags),
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user