Replace flag text with const (#1391)
This commit is contained in:
@@ -22,51 +22,42 @@ 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"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type ListSubCommand struct {
|
||||
client *client.Client
|
||||
triggerNamespace string
|
||||
filterFunctionName string
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
func List(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) complete(flags cli.Input) error {
|
||||
opts.triggerNamespace = flags.String("triggerNamespace")
|
||||
opts.filterFunctionName = flags.String("function")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(flags cli.Input) error {
|
||||
hts, err := opts.client.HTTPTriggerList(opts.triggerNamespace)
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
hts, err := opts.client.HTTPTriggerList(input.String(flagkey.NamespaceTrigger))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing HTTP triggers")
|
||||
}
|
||||
|
||||
filterFunctionName := input.String(flagkey.HtFnName)
|
||||
|
||||
var triggers []fv1.HTTPTrigger
|
||||
for _, ht := range hts {
|
||||
// TODO: list canary http triggers as well.
|
||||
if len(opts.filterFunctionName) == 0 ||
|
||||
(len(opts.filterFunctionName) > 0 && opts.filterFunctionName == ht.Spec.FunctionReference.Name) {
|
||||
if len(filterFunctionName) == 0 ||
|
||||
(len(filterFunctionName) > 0 && filterFunctionName == ht.Spec.FunctionReference.Name) {
|
||||
|
||||
triggers = append(triggers, ht)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user