From a0aa7bf6d18bbeccc48447bb859ffb8fe28da3dc Mon Sep 17 00:00:00 2001 From: Eduard Voiculescu Date: Thu, 29 Feb 2024 13:53:11 -0500 Subject: [PATCH] show warning message only when running kubectl get --watch-only --- staging/src/k8s.io/kubectl/pkg/cmd/get/get.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/get/get.go b/staging/src/k8s.io/kubectl/pkg/cmd/get/get.go index f16586994af..31d4cbdb3f3 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/get/get.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/get/get.go @@ -267,9 +267,13 @@ func (o *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri } switch { - case o.Watch || o.WatchOnly: + case o.Watch: if len(o.SortBy) > 0 { - fmt.Fprintf(o.IOStreams.ErrOut, "warning: --watch or --watch-only requested, --sort-by will be ignored\n") + fmt.Fprintf(o.IOStreams.ErrOut, "warning: --watch requested, --sort-by will be ignored for watch events received\n") + } + case o.WatchOnly: + if len(o.SortBy) > 0 { + fmt.Fprintf(o.IOStreams.ErrOut, "warning: --watch-only requested, --sort-by will be ignored\n") } default: if len(args) == 0 && cmdutil.IsFilenameSliceEmpty(o.Filenames, o.Kustomize) {