Don't bypass filter on generic output

It is inconsistent and confusing (filtering is orthogonal from output)
and we don't want to regress behavior from 1.5.
This commit is contained in:
Clayton Coleman 2017-03-01 18:33:08 -05:00
parent 102f267b6a
commit 4e7c10a520
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3
3 changed files with 10 additions and 15 deletions

View File

@ -76,7 +76,7 @@ kube::test::object_assert() {
local args=${5:-}
for j in $(seq 1 ${tries}); do
res=$(eval kubectl get "${kube_flags[@]}" ${args} $object -o go-template=\"$request\")
res=$(eval kubectl get -a "${kube_flags[@]}" ${args} $object -o go-template=\"$request\")
if [[ "$res" =~ ^$expected$ ]]; then
echo -n ${green}
echo "$(kube::test::get_caller 3): Successful get $object $request: $res"
@ -103,7 +103,7 @@ kube::test::get_object_jsonpath_assert() {
local request=$2
local expected=$3
res=$(eval kubectl get "${kube_flags[@]}" $object -o jsonpath=\"$request\")
res=$(eval kubectl get -a "${kube_flags[@]}" $object -o jsonpath=\"$request\")
if [[ "$res" =~ ^$expected$ ]]; then
echo -n ${green}

View File

@ -54,11 +54,12 @@ var (
` + valid_resources + `
This command will hide resources that have completed. For instance, pods that are in the Succeeded or Failed phases.
You can see the full results for any resource by providing the '--show-all' flag.
This command will hide resources that have completed, such as pods that are
in the Succeeded or Failed phases. You can see the full results for any
resource by providing the '--show-all' flag.
By specifying the output as 'template' and providing a Go template as the value
of the --template flag, you can filter the attributes of the fetched resource(s).`)
of the --template flag, you can filter the attributes of the fetched resources.`)
get_example = templates.Examples(`
# List all pods in ps output format.
@ -184,13 +185,6 @@ func RunGet(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args [
return cmdutil.UsageError(cmd, usageString)
}
// always show resources when getting by name or filename, or if the output
// is machine-consumable, or if multiple resource kinds were requested.
if cmdutil.OutputsRawFormat(cmd) {
if !cmd.Flag("show-all").Changed {
cmd.Flag("show-all").Value.Set("true")
}
}
export := cmdutil.GetFlagBool(cmd, "export")
filterFuncs := f.DefaultResourceFilterFunc()

View File

@ -229,10 +229,11 @@ func TestGetObjectsFiltered(t *testing.T) {
{args: []string{"pods", "foo"}, flags: map[string]string{"show-all": "false"}, resp: first, expect: []runtime.Object{first}},
{args: []string{"pods"}, flags: map[string]string{"show-all": "true"}, resp: pods, expect: []runtime.Object{first, second}},
{args: []string{"pods/foo"}, resp: first, expect: []runtime.Object{first}},
{args: []string{"pods"}, flags: map[string]string{"output": "yaml"}, resp: pods, expect: []runtime.Object{first, second}},
{args: []string{"pods"}, flags: map[string]string{"output": "yaml"}, resp: pods, expect: []runtime.Object{second}},
{args: []string{}, flags: map[string]string{"filename": "../../../examples/storage/cassandra/cassandra-controller.yaml"}, resp: pods, expect: []runtime.Object{first, second}},
{args: []string{"pods"}, resp: pods, expect: []runtime.Object{second}},
{args: []string{"pods"}, flags: map[string]string{"show-all": "true", "output": "yaml"}, resp: pods, expect: []runtime.Object{first, second}},
{args: []string{"pods"}, flags: map[string]string{"show-all": "false"}, resp: pods, expect: []runtime.Object{second}},
}
@ -731,8 +732,8 @@ func TestGetByFormatForcesFlag(t *testing.T) {
cmd.Run(cmd, []string{"pods"})
showAllFlag, _ := cmd.Flags().GetBool("show-all")
if !showAllFlag {
t.Errorf("expected showAll to be true when getting resource by name")
if showAllFlag {
t.Errorf("expected showAll to not be true when getting resource")
}
}