deprecate --show-all

This commit is contained in:
David Eads 2018-02-22 08:19:12 -05:00
parent c153aff99f
commit c9cb705816
2 changed files with 9 additions and 7 deletions

View File

@ -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")

View File

@ -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.