Skip to content

Commit

Permalink
Don't flatten schemas for type idents we don't know about
Browse files Browse the repository at this point in the history
I hit this problem with cases where there are multiple packages with the same group and version. The schema patcher would hit a nil pointer trying to flatten a schema for a kind that exists in one package, but not another, because it seems to assume that everything's in one package. By skipping cases where the parser hasn't already found the given kind in the given package, we got past that panic and everything seems to work correctly.

Signed-off-by: Andrew Bayer <[email protected]>
  • Loading branch information
abayer committed Sep 29, 2021
1 parent 699d149 commit c8009f3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/schemapatcher/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func (g Generator) Generate(ctx *genall.GenerationContext) (result error) {
}

typeIdent := crdgen.TypeIdent{Package: pkg, Name: groupKind.Kind}
if _, ok := parser.Types[typeIdent]; !ok {
continue
}
parser.NeedFlattenedSchemaFor(typeIdent)

fullSchema := parser.FlattenedSchemata[typeIdent]
Expand Down

0 comments on commit c8009f3

Please sign in to comment.