mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
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:
parent
102f267b6a
commit
4e7c10a520
@ -76,7 +76,7 @@ kube::test::object_assert() {
|
|||||||
local args=${5:-}
|
local args=${5:-}
|
||||||
|
|
||||||
for j in $(seq 1 ${tries}); do
|
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
|
if [[ "$res" =~ ^$expected$ ]]; then
|
||||||
echo -n ${green}
|
echo -n ${green}
|
||||||
echo "$(kube::test::get_caller 3): Successful get $object $request: $res"
|
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 request=$2
|
||||||
local expected=$3
|
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
|
if [[ "$res" =~ ^$expected$ ]]; then
|
||||||
echo -n ${green}
|
echo -n ${green}
|
||||||
|
@ -54,11 +54,12 @@ var (
|
|||||||
|
|
||||||
` + valid_resources + `
|
` + valid_resources + `
|
||||||
|
|
||||||
This command will hide resources that have completed. For instance, pods that are in the Succeeded or Failed phases.
|
This command will hide resources that have completed, such as pods that are
|
||||||
You can see the full results for any resource by providing the '--show-all' flag.
|
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
|
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(`
|
get_example = templates.Examples(`
|
||||||
# List all pods in ps output format.
|
# 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)
|
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")
|
export := cmdutil.GetFlagBool(cmd, "export")
|
||||||
|
|
||||||
filterFuncs := f.DefaultResourceFilterFunc()
|
filterFuncs := f.DefaultResourceFilterFunc()
|
||||||
|
@ -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", "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"}, 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/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{}, 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"}, 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}},
|
{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"})
|
cmd.Run(cmd, []string{"pods"})
|
||||||
|
|
||||||
showAllFlag, _ := cmd.Flags().GetBool("show-all")
|
showAllFlag, _ := cmd.Flags().GetBool("show-all")
|
||||||
if !showAllFlag {
|
if showAllFlag {
|
||||||
t.Errorf("expected showAll to be true when getting resource by name")
|
t.Errorf("expected showAll to not be true when getting resource")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user