Don't print the "filtered" message on generic output

Unify the various output displays and make them simpler. Don't write to
glog, but only output the info when `-v 2` to stderr.
This commit is contained in:
Clayton Coleman
2017-03-01 18:34:47 -05:00
parent 4e7c10a520
commit 34e4337e57
3 changed files with 27 additions and 35 deletions

View File

@@ -698,9 +698,26 @@ func FilterResourceList(obj runtime.Object, filterFuncs kubectl.Filters, filterO
return filterCount, list, nil
}
func PrintFilterCount(hiddenObjNum int, resource string, options *printers.PrintOptions) {
if !options.NoHeaders && !options.ShowAll && hiddenObjNum > 0 {
glog.V(2).Infof(" info: %d completed object(s) was(were) not shown in %s list. Pass --show-all to see all objects.\n\n", hiddenObjNum, resource)
// PrintFilterCount displays informational messages based on the number of resources found, hidden, or
// config flags shown.
func PrintFilterCount(out io.Writer, found, hidden, errors int, resource string, options *printers.PrintOptions, ignoreNotFound bool) {
switch {
case errors > 0 || ignoreNotFound:
// print nothing
case found <= hidden:
if found == 0 {
fmt.Fprintln(out, "No resources found.")
} else {
fmt.Fprintln(out, "No resources found, use --show-all to see completed objects.")
}
case hidden > 0 && !options.ShowAll && !options.NoHeaders:
if glog.V(2) {
if hidden > 1 {
fmt.Fprintf(out, "info: %d objects not shown, use --show-all to see completed objects.\n", hidden)
} else {
fmt.Fprintf(out, "info: 1 object not shown, use --show-all to see completed objects.\n")
}
}
}
}