Improve error message for missing CRDs

Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>
This commit is contained in:
Eddie Zaneski 2022-01-05 21:34:45 -07:00
parent e9fc23e31e
commit dfcc141c91
No known key found for this signature in database
GPG Key ID: 6B264594A44BB3EF

View File

@ -20,6 +20,7 @@ import (
"fmt"
"reflect"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
@ -64,6 +65,10 @@ func (m *mapper) infoForData(data []byte, source string) (*Info, error) {
}
mapping, err := restMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
if err != nil {
if _, ok := err.(*meta.NoKindMatchError); ok {
return nil, fmt.Errorf("resource mapping not found for name: %q namespace: %q from %q: %v\nensure CRDs are installed first",
name, namespace, source, err)
}
return nil, fmt.Errorf("unable to recognize %q: %v", source, err)
}
ret.Mapping = mapping