Automatic merge from submit-queue (batch tested with PRs 63669, 63511, 63561, 63289). 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>.
cleanup TODOs from PrintFlags wiring
**Release note**:
```release-note
NONE
```
Address TODOs from PrintFlags wiring
cc @soltysh @deads2k
Automatic merge from submit-queue (batch tested with PRs 59284, 63602). 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>.
category expansion can only come from the server
A couple release ago we moved category expansion to the server instead of hardcoding it in the client. Similar to restmappings, there is no valid client-side expansion anymore, so this removes the code that hardcoded the list and moves the category expansion to the same package as our discovery based restmappers.
@kubernetes/sig-cli-maintainers
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 59284, 63602). 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>.
Exclude keys containing empty patches in the final patch
**What this PR does / why we need it**:
This minimizes the 3-way JSON merge patch generated when calculating the patch necessary to send to the server. It does this by removing empty maps created from deleting keys in the keepOrDeleteNullInObj method.
This is not only a slight performance improvement (less PATCH requests) but also necessary when working with custom resources that have RBAC restrictions.
**Which issue(s) this PR fixes**: N/A
**Special notes for your reviewer**: N/A
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 63597, 63599). 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>.
push ToRESTMapper down a layer
The RESTMapper is needed to drive some use-cases for a dynamic client and takes a little bit of wiring (nested restmappers). This pull pushes that into information derived from the kubeconfig flags to allow easy re-use.
@kubernetes/sig-cli-maintainers
/assign @juanvallejo
/assign @soltysh
assigned to original creators.
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 63526, 60371, 63444). 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>.
Support completion for kubectl cp
**What this PR does / why we need it**: With this PR, kubectl cp supports completion. I tested this PR in bash and zsh.
```
$ kubectl cp kube-system/<tab>
kube-system/kube-state-metrics-769566fdfb-4v52s: kube-system/kubernetes-dashboard-6b6ddbd46-t5bv9: kube-system/prometheus-694594c45b-qk5lq:
```
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixeskubernetes/kubectl#5
**Special notes for your reviewer**: @cblecker
**Release note**:
```release-note
`kubectl cp` supports completion.
```
Automatic merge from submit-queue (batch tested with PRs 63070, 63536). 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>.
use IOStreams for cli commands
Scrubs the last commands to use IOStreams for consistency and testability.
@kubernetes/sig-cli-maintainers
/assign @juanvallejo
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 63291, 63490, 60445, 63507, 63524). 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>.
move client based restmappers to client-go
Moves the client-based restmappers to client-go where everyone who needs them can have access.
```release-note
the shortcuts which were moved server-side in at least 1.9 have been removed from being hardcoded in kubectl
```
@kubernetes/sig-cli-maintainers @kubernetes/sig-api-machinery-pr-reviews
Automatic merge from submit-queue (batch tested with PRs 63291, 63490, 60445, 63507, 63524). 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>.
default the ignorenotfound for delete when selecting objects
When selecting resources and then deleting them (as opposed to specifically indicating a resource to delete) we should default to not failing if something disappeared partway through. This is quite common when label selecting deletes and GC runs before you get to a dependent object.
I also took the liberty of doing complete work in complete instead of validate.
```release-note
`kubectl delete` with selection criteria defaults to ignoring not found errors
```
@kubernetes/sig-cli-maintainers
Automatic merge from submit-queue (batch tested with PRs 63291, 63490, 60445, 63507, 63524). 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>.
clean unused variables
**What this PR does / why we need it**:
clean unused variables on set.go
**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
```
Automatic merge from submit-queue (batch tested with PRs 63315, 63383, 63318, 63439). 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>.
drive resourcebuilder from kubeconfig, allow scheme specification
This updates the resource builder to work based on a kubeconfig to allow future chaining of flags. It also allow specification of the scheme you want for your actual decoding.
@kubernetes/sig-cli-maintainers
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 63421, 63432, 63333). 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>.
update tests to be specific about the versions they are testing
When setting up tests, you want to rely on your own scheme. This eliminates coupling to floating versions which gives unnecessary flexibility in most cases and prevents testing all the versions you need.
@liggitt scrubs unnecessary deps.
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 63421, 63432, 63333). 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>.
slim printer interface down to printing
The printer interface only needs to know how to print. This reduces it's interface to scope it to printing.
@kubernetes/sig-cli-maintainers
@soltysh @juanvallejo you've been active in the area
/assign @juanvallejo
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 63258, 63398, 63403). 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>.
remove unnessary kubectl conversions
Working with unstructured types means that conversion can be eliminated. This pulls it from places I noticed.
/assign @juanvallejo
@kubernetes/sig-cli-misc
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 63258, 63398, 63403). 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>.
stop using Info.Mappings when they may not be present
On a resource builder, you cannot logically have a RESTMapping or a Client if you're running a local action. Reliance on the `info.Client` and `info.Mapping` is a bug we need to fix. This updates the docs and eliminates unnecessary reliance. Other hits I found didn't have `--local` options, so we're safe or had them and and were already broken. I think we'll be able to help them after making our creation flow obvious.
@kubernetes/sig-cli-maintainers
```release-note
NONE
```
Automatic merge from submit-queue. 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>.
Update all script shebangs to use /usr/bin/env interpreter instead of /bin/interpreter
This is required to support systems where bash doesn't reside in /bin (such as NixOS, or the *BSD family) and allow users to specify a different interpreter version through $PATH manipulation.
https://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html
```release-note
Use /usr/bin/env in all script shebangs to increase portability.
```
Automatic merge from submit-queue. 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>.
fix namespace miss bug
**What this PR does / why we need it**:
This patch fixes the namespace miss problems.
I am not sure if this is the correct way it should be fixed.
Just offer a solution.
**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#62059
**Special notes for your reviewer**:
**Release note**:
```release-note
NONE
```