Skip to content

Commit b09fb54

Browse files
coderangerDirectXMan12
authored andcommitted
Handle the error type in crd gen
CRD gen searches for objectmeta and typemeta by traversing fields of structs, and needs to handle the weird case of error, which is a universe type but not a builtin, so it doesn't have a package.
1 parent 84501b7 commit b09fb54

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/crd/gen.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ func findKubeKinds(parser *Parser, metav1Pkg *loader.Package) []schema.GroupKind
148148
// ObjectMeta and TypeMeta are named types
149149
continue
150150
}
151+
if namedField.Obj().Pkg() == nil {
152+
// Embedded non-builtin universe type (specifically, it's probably `error`),
153+
// so it can't be ObjectMeta or TypeMeta
154+
continue
155+
}
151156
fieldPkgPath := loader.NonVendorPath(namedField.Obj().Pkg().Path())
152157
fieldPkg := pkg.Imports()[fieldPkgPath]
153158
if fieldPkg != metav1Pkg {

0 commit comments

Comments
 (0)