Replace flag text with const (#1391)
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
@@ -37,34 +38,34 @@ type ListSubCommand struct {
|
||||
pkgNamespace string
|
||||
}
|
||||
|
||||
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)
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) complete(flags cli.Input) error {
|
||||
func (opts *ListSubCommand) complete(input cli.Input) error {
|
||||
// option for the user to list all orphan packages (not referenced by any function)
|
||||
opts.listOrphans = flags.Bool("orphan")
|
||||
opts.status = flags.String("status")
|
||||
opts.pkgNamespace = flags.String("pkgNamespace")
|
||||
opts.listOrphans = input.Bool(flagkey.PkgOrphan)
|
||||
opts.status = input.String(flagkey.PkgStatus)
|
||||
opts.pkgNamespace = input.String(flagkey.NamespacePackage)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(flags cli.Input) error {
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
pkgList, err := opts.client.PackageList(opts.pkgNamespace)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -80,6 +81,7 @@ func (opts *ListSubCommand) run(flags cli.Input) error {
|
||||
|
||||
for _, pkg := range pkgList {
|
||||
show := true
|
||||
// TODO improve list speed when --orphan
|
||||
if opts.listOrphans {
|
||||
fnList, err := GetFunctionsByPackage(opts.client, pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user