Signed-off-by: shenpeng.sp0916 <shenpeng.sp0916@bytedance.com>
Backport the fix from #31578 to dev-v3 branch.
The installCRDs function previously could panic in several scenarios:
- When a CRD object has a nil File field (accessing obj.File.Data)
- When a CRD object has nil File.Data (passing nil to KubeClient.Build)
- When KubeClient.Build returns an empty resource list (accessing res[0])
- When RESTClientGetter is nil (calling ToDiscoveryClient/ToRESTMapper)
Added nil and empty checks to return descriptive errors instead of
panicking in all these cases.
Closes#31552
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: shenpeng.sp0916 <shenpeng.sp0916@bytedance.com>