Merge pull request #12189 from feihujiang/describeKindNoArguments
kubectl describe <kind> work with no arguments
This commit is contained in:
@@ -56,6 +56,9 @@ $ kubectl describe pods/nginx
|
||||
// Describe a pod using the data in pod.json.
|
||||
$ kubectl describe -f pod.json
|
||||
|
||||
// Describe all pods
|
||||
$ kubectl describe pods
|
||||
|
||||
// Describe pods by label name=myLabel
|
||||
$ kubectl describe po -l name=myLabel
|
||||
|
||||
@@ -100,7 +103,7 @@ func RunDescribe(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
|
||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||
FilenameParam(enforceNamespace, filenames...).
|
||||
SelectorParam(selector).
|
||||
ResourceTypeOrNameArgs(false, args...).
|
||||
ResourceTypeOrNameArgs(true, args...).
|
||||
Flatten().
|
||||
Do()
|
||||
err = r.Err()
|
||||
|
@@ -81,3 +81,22 @@ func TestDescribeObject(t *testing.T) {
|
||||
t.Errorf("unexpected output: %s", buf.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribeListObjects(t *testing.T) {
|
||||
pods, _, _ := testData()
|
||||
f, tf, codec := NewAPIFactory()
|
||||
d := &testDescriber{Output: "test output"}
|
||||
tf.Describer = d
|
||||
tf.Client = &client.FakeRESTClient{
|
||||
Codec: codec,
|
||||
Resp: &http.Response{StatusCode: 200, Body: objBody(codec, pods)},
|
||||
}
|
||||
|
||||
tf.Namespace = "test"
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
cmd := NewCmdDescribe(f, buf)
|
||||
cmd.Run(cmd, []string{"pods"})
|
||||
if buf.String() != fmt.Sprintf("%s\n\n%s\n\n", d.Output, d.Output) {
|
||||
t.Errorf("unexpected output: %s", buf.String())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user