fix: print "No functions found in [ns] namespace" for kn func list (#240)

When there are no functions deployed, the `kn func list` command now says so.

Fixes: https://github.com/boson-project/faas/issues/228

Signed-off-by: Lance Ball <lball@redhat.com>
This commit is contained in:
Lance Ball 2020-12-11 09:34:53 -05:00 committed by GitHub
parent 6470d9e574
commit 61ea8d4fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -19,7 +19,7 @@ import (
func init() {
root.AddCommand(listCmd)
listCmd.Flags().BoolP("all-namespaces", "A", false, "List functions in all namespaces. If set, the --namespace flag is ignored.")
listCmd.Flags().StringP("namespace", "n", "", "Namespace of the function to undeploy. By default, the functions of the actual active namespace are listed. (Env: $FUNC_NAMESPACE)")
listCmd.Flags().StringP("namespace", "n", "", "Namespace to search for functions. By default, the functions of the actual active namespace are listed. (Env: $FUNC_NAMESPACE)")
listCmd.Flags().StringP("output", "o", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_OUTPUT)")
err := listCmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList)
if err != nil {
@ -75,7 +75,16 @@ func runList(cmd *cobra.Command, args []string) (err error) {
return
}
<<<<<<< HEAD
write(os.Stdout, listItems(items), config.Output)
=======
if len(items) < 1 {
fmt.Printf("No functions found in %v namespace\n", lister.Namespace)
return
}
write(os.Stdout, listItems(items), config.Format)
>>>>>>> ca24764... fix: print "No functions found in [ns] namespace" for kn func list
return
}