From 32c718ea13a7bc3aa02449bb406b30a126fc13c0 Mon Sep 17 00:00:00 2001 From: Leonardo Luz Almeida Date: Thu, 9 May 2024 10:51:48 -0400 Subject: [PATCH] fix: handle nil ParseableType from GVKParser Signed-off-by: Leonardo Luz Almeida --- pkg/diff/diff.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/diff/diff.go b/pkg/diff/diff.go index 2581bd2c5..6c9519abb 100644 --- a/pkg/diff/diff.go +++ b/pkg/diff/diff.go @@ -208,6 +208,10 @@ func removeWebhookMutation(predictedLive, live *unstructured.Unstructured, gvkPa } gvk := predictedLive.GetObjectKind().GroupVersionKind() pt := gvkParser.Type(gvk) + if pt == nil { + return nil, fmt.Errorf("unable to resolve parseableType for gvk: %s", gvk) + } + typedPredictedLive, err := pt.FromUnstructured(predictedLive.Object) if err != nil { return nil, fmt.Errorf("error converting predicted live state from unstructured to %s: %w", gvk, err) @@ -316,6 +320,9 @@ func structuredMergeDiff(p *SMDParams) (*DiffResult, error) { gvk := p.config.GetObjectKind().GroupVersionKind() pt := gescheme.ResolveParseableType(gvk, p.gvkParser) + if pt == nil { + return nil, fmt.Errorf("unable to resolve parseableType for gvk: %s", gvk) + } // Build typed value from live and config unstructures tvLive, err := pt.FromUnstructured(p.live.Object)