From a3d87b57ebecc180eb36c9878aa86ac9f880ac2e Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Fri, 3 Feb 2023 20:46:06 +0100 Subject: [PATCH] return error instead of panic Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- pkg/client/apiutil/dynamicrestmapper.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/client/apiutil/dynamicrestmapper.go b/pkg/client/apiutil/dynamicrestmapper.go index 17fadeeac5..66f488c0f1 100644 --- a/pkg/client/apiutil/dynamicrestmapper.go +++ b/pkg/client/apiutil/dynamicrestmapper.go @@ -17,6 +17,7 @@ limitations under the License. package apiutil import ( + "fmt" "net/http" "sync" "sync/atomic" @@ -78,7 +79,7 @@ func WithCustomMapper(newMapper func() (meta.RESTMapper, error)) DynamicRESTMapp // configure the RESTMapper. func NewDynamicRESTMapper(cfg *rest.Config, httpClient *http.Client, opts ...DynamicRESTMapperOption) (meta.RESTMapper, error) { if httpClient == nil { - panic("httpClient must not be nil") + return nil, fmt.Errorf("httpClient must not be nil, consider using rest.HTTPClientFor(c) to create a client") } client, err := discovery.NewDiscoveryClientForConfigAndClient(cfg, httpClient)