Merge pull request #62512 from dixudx/cli_gvk_list

Automatic merge from submit-queue (batch tested with PRs 62632, 62789, 62512, 62848). 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>.

kubectl stops rendering List as suffix kind name for CRD resources

**What this PR does / why we need it**:
`List` should not be treated as suffix when validating CRD objects.
Removing this validation won't break anything.

**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 #62410

**Special notes for your reviewer**:
/assign liggitt deads2k 
/cc nikhita soltysh 

**Release note**:

```release-note
kubectl stops rendering List as suffix kind name for CRD resources
```
This commit is contained in:
Kubernetes Submit Queue 2018-04-19 08:58:16 -07:00 committed by GitHub
commit 07c64d1d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -18,7 +18,6 @@ package validation
import (
"errors"
"strings"
"k8s.io/apimachinery/pkg/runtime/schema"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
@ -54,7 +53,7 @@ func (v *SchemaValidation) ValidateBytes(data []byte) error {
return utilerrors.NewAggregate(errs)
}
if strings.HasSuffix(gvk.Kind, "List") {
if (gvk == schema.GroupVersionKind{Version: "v1", Kind: "List"}) {
return utilerrors.NewAggregate(v.validateList(obj))
}

View File

@ -394,4 +394,16 @@ items:
`))
Expect(err.Error()).To(Equal("[kind not set, apiVersion not set]"))
})
It("is fine with crd resource with List as a suffix kind name, which may not be a list of resources", func() {
err := validator.ValidateBytes([]byte(`
apiVersion: fake.com/v1
kind: FakeList
metadata:
name: fake
spec:
foo: bar
`))
Expect(err).To(BeNil())
})
})