From c9cb70581660776aa4d72bc2de2361f5bc249a7d Mon Sep 17 00:00:00 2001 From: David Eads Date: Thu, 22 Feb 2018 08:19:12 -0500 Subject: [PATCH] deprecate --show-all --- pkg/kubectl/cmd/resource/get_test.go | 13 +++++++------ pkg/kubectl/cmd/util/printing.go | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/kubectl/cmd/resource/get_test.go b/pkg/kubectl/cmd/resource/get_test.go index a56f18f15e7..d7459240200 100644 --- a/pkg/kubectl/cmd/resource/get_test.go +++ b/pkg/kubectl/cmd/resource/get_test.go @@ -386,14 +386,14 @@ func TestGetObjectsFiltered(t *testing.T) { flags map[string]string expect string }{ + {args: []string{"pods", "foo"}, flags: map[string]string{"show-all": "true"}, resp: first, expect: "pod/foo\n"}, {args: []string{"pods", "foo"}, resp: first, expect: "pod/foo\n"}, - {args: []string{"pods", "foo"}, flags: map[string]string{"show-all": "false"}, resp: first, expect: "pod/foo\n"}, - {args: []string{"pods"}, flags: map[string]string{"show-all": "true"}, resp: pods, expect: "pod/foo\npod/bar\n"}, - {args: []string{"pods/foo"}, resp: first, expect: "pod/foo\n"}, - {args: []string{"pods"}, flags: map[string]string{"output": "yaml"}, resp: pods, expect: "pod/bar\n"}, - {args: []string{}, flags: map[string]string{"filename": "../../../../examples/storage/cassandra/cassandra-controller.yaml"}, resp: pods, expect: "pod/foo\npod/bar\n"}, + {args: []string{"pods"}, resp: pods, expect: "pod/foo\npod/bar\n"}, + {args: []string{"pods/foo"}, flags: map[string]string{"show-all": "false"}, resp: first, expect: "pod/foo\n"}, + {args: []string{"pods"}, flags: map[string]string{"show-all": "false", "output": "yaml"}, resp: pods, expect: "pod/bar\n"}, + {args: []string{}, flags: map[string]string{"show-all": "false", "filename": "../../../../examples/storage/cassandra/cassandra-controller.yaml"}, resp: pods, expect: "pod/foo\npod/bar\n"}, - {args: []string{"pods"}, resp: pods, expect: "pod/bar\n"}, + {args: []string{"pods"}, flags: map[string]string{"show-all": "false"}, resp: pods, expect: "pod/bar\n"}, {args: []string{"pods"}, flags: map[string]string{"show-all": "true", "output": "yaml"}, resp: pods, expect: "pod/foo\npod/bar\n"}, {args: []string{"pods"}, flags: map[string]string{"show-all": "false"}, resp: pods, expect: "pod/bar\n"}, } @@ -991,6 +991,7 @@ func TestGetByFormatForcesFlag(t *testing.T) { cmd := NewCmdGet(f, buf, errBuf) cmd.SetOutput(buf) cmd.Flags().Lookup("output").Value.Set("yaml") + cmd.Flags().Set("show-all", "false") cmd.Run(cmd, []string{"pods"}) showAllFlag, _ := cmd.Flags().GetBool("show-all") diff --git a/pkg/kubectl/cmd/util/printing.go b/pkg/kubectl/cmd/util/printing.go index 0e8c11f92c7..18098f20f90 100644 --- a/pkg/kubectl/cmd/util/printing.go +++ b/pkg/kubectl/cmd/util/printing.go @@ -52,7 +52,8 @@ func AddNonDeprecatedPrinterFlags(cmd *cobra.Command) { cmd.Flags().String("template", "", "Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].") cmd.MarkFlagFilename("template") cmd.Flags().String("sort-by", "", "If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.") - cmd.Flags().BoolP("show-all", "a", false, "When printing, show all resources (default hide terminated pods.)") + cmd.Flags().BoolP("show-all", "a", true, "When printing, show all resources (default hide terminated pods.)") + cmd.Flags().MarkDeprecated("show-all", "will be removed in an upcoming release") } // AddOutputFlagsForMutation adds output related flags to a command. Used by mutations only.