Skip to content

Commit 0aecd43

Browse files
authored
fix: handle nil ParseableType from GVKParser (argoproj#574)
* fix: handle nil ParseableType from GVKParser Signed-off-by: Leonardo Luz Almeida <[email protected]> * address review comments Signed-off-by: Leonardo Luz Almeida <[email protected]> --------- Signed-off-by: Leonardo Luz Almeida <[email protected]>
1 parent 86a3688 commit 0aecd43

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/diff/diff.go

+7
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ func removeWebhookMutation(predictedLive, live *unstructured.Unstructured, gvkPa
208208
}
209209
gvk := predictedLive.GetObjectKind().GroupVersionKind()
210210
pt := gvkParser.Type(gvk)
211+
if pt == nil {
212+
return nil, fmt.Errorf("unable to resolve parseableType for GroupVersionKind: %s", gvk)
213+
}
214+
211215
typedPredictedLive, err := pt.FromUnstructured(predictedLive.Object)
212216
if err != nil {
213217
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) {
316320

317321
gvk := p.config.GetObjectKind().GroupVersionKind()
318322
pt := gescheme.ResolveParseableType(gvk, p.gvkParser)
323+
if pt == nil {
324+
return nil, fmt.Errorf("unable to resolve parseableType for GroupVersionKind: %s", gvk)
325+
}
319326

320327
// Build typed value from live and config unstructures
321328
tvLive, err := pt.FromUnstructured(p.live.Object)

0 commit comments

Comments
 (0)