Merge pull request #57511 from niuzhenguo/show-kind

Automatic merge from submit-queue (batch tested with PRs 57511, 57978). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Small improvement of showKind get

**What this PR does / why we need it**:
Given the complexity of determining whether to show resource with kind, this PR will be a small improvement when with `--show-kind=true`. There's no need to waste time to run the complex logic if we already decided to show resource with kind.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-01-09 15:19:30 -08:00 committed by GitHub
commit b2ffdb73ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,11 +301,7 @@ func (options *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []str
useOpenAPIPrintColumns := cmdutil.GetFlagBool(cmd, useOpenAPIPrintColumnFlagLabel)
showKind := options.ShowKind
// TODO: abstract more cleanly
if resource.MultipleTypesRequested(args) || cmdutil.MustPrintWithKinds(objs, infos, sorter) {
showKind = true
}
showKind := options.ShowKind || resource.MultipleTypesRequested(args) || cmdutil.MustPrintWithKinds(objs, infos, sorter)
filteredResourceCount := 0
noHeaders := cmdutil.GetFlagBool(cmd, "no-headers")