Skip to content

Commit a3d87b5

Browse files
committed
return error instead of panic
Signed-off-by: Tim Ramlot <[email protected]>
1 parent b9429e7 commit a3d87b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/client/apiutil/dynamicrestmapper.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package apiutil
1818

1919
import (
20+
"fmt"
2021
"net/http"
2122
"sync"
2223
"sync/atomic"
@@ -78,7 +79,7 @@ func WithCustomMapper(newMapper func() (meta.RESTMapper, error)) DynamicRESTMapp
7879
// configure the RESTMapper.
7980
func NewDynamicRESTMapper(cfg *rest.Config, httpClient *http.Client, opts ...DynamicRESTMapperOption) (meta.RESTMapper, error) {
8081
if httpClient == nil {
81-
panic("httpClient must not be nil")
82+
return nil, fmt.Errorf("httpClient must not be nil, consider using rest.HTTPClientFor(c) to create a client")
8283
}
8384

8485
client, err := discovery.NewDiscoveryClientForConfigAndClient(cfg, httpClient)

0 commit comments

Comments
 (0)