From da6cb61ad4f64cf5585b932c89b45705db1e210d Mon Sep 17 00:00:00 2001 From: Richard Kettelerij Date: Mon, 11 Mar 2024 09:53:37 +0100 Subject: [PATCH] Fix SIGSERV when RawSpec is nil --- pkg/crd/schema.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/crd/schema.go b/pkg/crd/schema.go index a5c2f28c9..d3b3436b7 100644 --- a/pkg/crd/schema.go +++ b/pkg/crd/schema.go @@ -341,7 +341,7 @@ func structToSchema(ctx *schemaContext, structType *ast.StructType) *apiext.JSON Properties: make(map[string]apiext.JSONSchemaProps), } - if ctx.info.RawSpec.Type != structType { + if ctx.info.RawSpec != nil && ctx.info.RawSpec.Type != structType { ctx.pkg.AddError(loader.ErrFromNode(fmt.Errorf("encountered non-top-level struct (possibly embedded), those aren't allowed"), structType)) return props }