k3s/pkg/kubectl/cmd/util
Kubernetes Submit Queue a13dee2337
Merge pull request #60990 from bmcstdio/bcustodio/kubectl-edit
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>.

Ensure reasons end up as comments in kubectl edit.

**What this PR does / why we need it**:

This PR helps making sure that all text in the header of the file is prefixed with `#` when using `kubectl edit` to fix schema validation errors. The problem is best described with an example:

*Before:*

```yaml
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
# mycrd "example-cr" was not valid:
# * []: Invalid value: map[string]interface {}{"apiVersion":"example.com/v1alpha1", "kind":"MyCRD", "metadata":map[string]interface {}{"clusterName":"", "creationTimestamp":"2018-03-09T16:16:41Z", "name":"example-cr", "namespace":"default", "resourceVersion":"12399", "selfLink":"", "uid":"4089f5bd-23b5-11e8-a33f-42010aa40081", "generation":0}, "spec":map[string]interface {}{"size":-1}}: validation failure list:
spec.size in body should be greater than or equal to 1
#
apiVersion: example.com/v1alpha1
kind: MyCRD
```

This obviously won't be accepted as input, the user having to manually add a `#` to the line in the header.

*After:*

```yaml
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
# mycrd "example-cr" was not valid:
# * []: Invalid value: map[string]interface {}{"apiVersion":"example.com/v1alpha1", "kind":"MyCRD", "metadata":map[string]interface {}{"clusterName":"", "creationTimestamp":"2018-03-09T16:16:41Z", "name":"example-cr", "namespace":"default", "resourceVersion":"12399", "selfLink":"", "uid":"4089f5bd-23b5-11e8-a33f-42010aa40081", "generation":0}, "spec":map[string]interface {}{"size":-1}}: validation failure list:
# spec.size in body should be greater than or equal to 1
#
apiVersion: example.com/v1alpha1
kind: MyCRD
```

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
(None that I am aware of)

**Special notes for your reviewer**:
(None)

**Release note**:

```release-note
Ensure reasons end up as comments in `kubectl edit`.
```
2018-03-30 11:23:29 -07:00
..
editor Ensure reasons end up as comments in kubectl edit. 2018-03-10 13:08:50 +00:00
env Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
jsonmerge update BUILD files 2017-10-15 18:18:13 -07:00
openapi Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
sanity update BUILD files 2017-10-15 18:18:13 -07:00
BUILD removes custom scalers from kubectl 2018-03-26 19:33:42 +02:00
cached_discovery.go discovery client not depend on pkg/api/legacyscheme 2017-11-02 14:59:21 -07:00
cached_discovery_test.go kubectl: Remove swagger 1.2 entirely. 2017-10-10 14:50:56 -07:00
clientcache.go Merge pull request #59042 from soltysh/issue25442 2018-02-23 14:01:44 -08:00
factory.go removes custom scalers from kubectl 2018-03-26 19:33:42 +02:00
factory_builder.go removes custom scalers from kubectl 2018-03-26 19:33:42 +02:00
factory_client_access.go --show-all is inert in v1.11 2018-03-21 09:13:21 +08:00
factory_object_mapping.go removes custom scalers from kubectl 2018-03-26 19:33:42 +02:00
factory_object_mapping_test.go Remove ClientSetForVersion & ClientConfigForVersion from factory 2018-02-22 15:50:27 +01:00
factory_test.go remove f.PrintObjectSpecificMessage 2018-02-21 21:06:49 -05:00
helpers.go --show-all is inert in v1.11 2018-03-21 09:13:21 +08:00
helpers_test.go pkg/apis/core: mechanical import fixes in dependencies 2017-11-09 12:14:08 +01:00
printing.go fix show-all option description 2018-03-12 10:34:08 +08:00
shortcut_restmapper.go Prefer exact resource name matches to shortname expansions 2018-01-26 01:45:38 -05:00
shortcut_restmapper_test.go Prefer exact resource name matches to shortname expansions 2018-01-26 01:45:38 -05:00