kubectl stops rendering List as suffix kind name for CRD resources
This commit is contained in:
		@@ -18,7 +18,6 @@ package validation
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"strings"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/runtime/schema"
 | 
						"k8s.io/apimachinery/pkg/runtime/schema"
 | 
				
			||||||
	utilerrors "k8s.io/apimachinery/pkg/util/errors"
 | 
						utilerrors "k8s.io/apimachinery/pkg/util/errors"
 | 
				
			||||||
@@ -54,7 +53,7 @@ func (v *SchemaValidation) ValidateBytes(data []byte) error {
 | 
				
			|||||||
		return utilerrors.NewAggregate(errs)
 | 
							return utilerrors.NewAggregate(errs)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if strings.HasSuffix(gvk.Kind, "List") {
 | 
						if (gvk == schema.GroupVersionKind{Version: "v1", Kind: "List"}) {
 | 
				
			||||||
		return utilerrors.NewAggregate(v.validateList(obj))
 | 
							return utilerrors.NewAggregate(v.validateList(obj))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -394,4 +394,16 @@ items:
 | 
				
			|||||||
`))
 | 
					`))
 | 
				
			||||||
		Expect(err.Error()).To(Equal("[kind not set, apiVersion not set]"))
 | 
							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())
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user