Skip to content

Commit

Permalink
Merge pull request #2178 from inteon/error_instead_of_panic
Browse files Browse the repository at this point in the history
馃尡Return an error if no httpClient is provided for `NewDynamicRESTMapper`
  • Loading branch information
k8s-ci-robot committed Feb 3, 2023
2 parents b9429e7 + a3d87b5 commit 5c0aa32
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/client/apiutil/dynamicrestmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package apiutil

import (
"fmt"
"net/http"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5c0aa32

Please sign in to comment.