From a2ef32442ab10099cb6d26210ec48c603023aa85 Mon Sep 17 00:00:00 2001 From: Abhijit Hoskeri Date: Sat, 10 Dec 2022 16:32:02 -0800 Subject: [PATCH] Check the correct error in d.downloadAPIs The error result of `d.downloadAPIs()` is set in `aerr`, not `err`. This prevents a nil-ptr dereference of apiGroups in the next step. Signed-off-by: Abhijit Hoskeri Kubernetes-commit: f8b99b1f09fb5d4d10b15e326c4b242cc705f007 --- discovery/discovery_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discovery/discovery_client.go b/discovery/discovery_client.go index 9025e888ec..43906190fb 100644 --- a/discovery/discovery_client.go +++ b/discovery/discovery_client.go @@ -196,7 +196,7 @@ func (d *DiscoveryClient) GroupsAndMaybeResources() (*metav1.APIGroupList, map[s } // Discovery groups and (possibly) resources downloaded from /apis. apiGroups, apiResources, aerr := d.downloadAPIs() - if err != nil { + if aerr != nil { return nil, nil, aerr } // Merge apis groups into the legacy groups.