k3s/pkg/kubectl
Kubernetes Submit Queue cf10f532d1 Merge pull request #41304 from liggitt/edit-refactor
Automatic merge from submit-queue

Make kubectl edit work with unstructured objects

Fixes https://github.com/kubernetes/kubernetes/issues/35993


1. First (before any other changes), added several test cases for complex edit scenarios:
   - [x] ensure the edit loop bails out if given the same result that already caused errors
   - [x] ensure an edited file with a syntax error is reopened preserving the input
   - [x] ensure objects with existing "caused-by" annotations get updated with the current command

2. Refactored the edit code to prep for switching to unstructured:
   - [x] made editFn operate on a slice of resource.Info objects passed as an arg, regardless of edit mode
   - [x] simplified short-circuiting logic when re-editing a file containing an error
   - [x] refactored how we build the various visitors (namespace enforcement, annotation application, patching, creating) so we could easily switch to just using a single visitor over a set of resource infos read from the updated input for all of them

3. Switched to using a resource builder to parse the stream of the user's edited output
   - [x] improve the error message you get on syntax errors
   - [x] preserve the user's input more faithfully (see how the captured testcase requests to the server changed to reflect exactly what the user edited)
   - [x] stopped doing client-side conversion (means deprecating `--output-version`)

4. Switched edit to work with generic objects
   - [x] use unstructured objects
   - [x] fall back to generic json merge patch for unrecognized group/version/kinds

5. Added new test cases
   - [x] schemaless objects falls back to generic json merge (covers TPR scenario)
   - [x] edit unknown version of known kind (version "v0" of storageclass) falls back to generic json merge

```release-note
`kubectl edit` now edits objects exactly as they were retrieved from the API. This allows using `kubectl edit` with third-party resources and extension API servers. Because client-side conversion is no longer done, the `--output-version` option is deprecated for `kubectl edit`. To edit using a particular API version, fully-qualify the resource, version, and group used to fetch the object (for example, `job.v1.batch/myjob`)
```
2017-02-14 18:34:30 -08:00
..
cmd Merge pull request #41304 from liggitt/edit-refactor 2017-02-14 18:34:30 -08:00
metricsutil Update generated files 2017-01-29 21:41:45 +01:00
resource Simplify 'kubectl edit' logic 2017-02-14 14:51:06 -05:00
testing refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
BUILD Update kubectl to work with new HPA objects 2017-02-07 22:25:28 -05:00
OWNERS Revert "update kubectl approvers" 2017-01-25 17:32:22 -08:00
apply.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
autoscale.go Update kubectl to work with new HPA objects 2017-02-07 22:25:28 -05:00
bash_comp_utils.go
cluster.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
cluster_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
clusterrolebinding.go Switch RBAC subject apiVersion to apiGroup in v1beta1 2017-02-13 15:33:09 -05:00
configmap.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
configmap_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
custom_column_printer.go move authoritative client-go utils out of pkg 2017-01-24 08:59:18 -05:00
custom_column_printer_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
deployment.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
deployment_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
describe.go Update kubectl to work with new HPA objects 2017-02-07 22:25:28 -05:00
describe_test.go Update kubectl to work with new HPA objects 2017-02-07 22:25:28 -05:00
doc.go
explain.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
generate.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
generate_test.go
history.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
interfaces.go find and replace 2017-01-20 08:04:53 -05:00
kubectl.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
kubectl_test.go
namespace.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
namespace_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
pdb.go move util/intstr to apimachinery 2017-01-30 12:46:59 -05:00
proxy_server.go find and replace 2017-01-20 08:04:53 -05:00
proxy_server_test.go Merge pull request #38789 from jessfraz/cleanup-temp-dirs 2017-01-20 12:34:58 -08:00
quota.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
quota_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
resource_filter.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
resource_printer.go Update kubectl to work with new HPA objects 2017-02-07 22:25:28 -05:00
resource_printer_test.go Update kubectl to work with new HPA objects 2017-02-07 22:25:28 -05:00
rolebinding.go Switch RBAC subject apiVersion to apiGroup in v1beta1 2017-02-13 15:33:09 -05:00
rollback.go refactor: move ListOptions references to metav1 2017-01-23 17:52:46 -05:00
rolling_updater.go move util/intstr to apimachinery 2017-01-30 12:46:59 -05:00
rolling_updater_test.go move util/intstr to apimachinery 2017-01-30 12:46:59 -05:00
rollout_status.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
rollout_status_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
run.go pkg/api/resource: move to apimachinery 2017-01-29 21:41:44 +01:00
run_test.go pkg/api/resource: move to apimachinery 2017-01-29 21:41:44 +01:00
scale.go refactor: move ListOptions references to metav1 2017-01-23 17:52:46 -05:00
scale_test.go move testing/core to client-go 2017-01-26 13:54:40 -05:00
secret.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
secret_for_docker_registry.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
secret_for_docker_registry_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
secret_for_tls.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
secret_for_tls_test.go move authoritative client-go utils out of pkg 2017-01-24 08:59:18 -05:00
secret_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
service.go Merge pull request #38183 from tianshapjq/remove-create-external-load-balancer 2017-02-07 11:33:41 -08:00
service_basic.go move util/intstr to apimachinery 2017-01-30 12:46:59 -05:00
service_basic_test.go move util/intstr to apimachinery 2017-01-30 12:46:59 -05:00
service_test.go Merge pull request #38183 from tianshapjq/remove-create-external-load-balancer 2017-02-07 11:33:41 -08:00
serviceaccount.go start the apimachinery repo 2017-01-11 09:09:48 -05:00
serviceaccount_test.go refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
sorted_resource_name_list.go
sorted_resource_name_list_test.go
sorting_printer.go Fix sorting printer with missing fields 2017-01-28 19:56:53 -02:00
sorting_printer_test.go Fix sorting printer with missing fields 2017-01-28 19:56:53 -02:00
stop.go pkg/util: move uuid and strategicpatch into k8s.io/apimachinery 2017-01-25 19:45:09 +01:00
stop_test.go move testing/core to client-go 2017-01-26 13:54:40 -05:00
versioned_client.go