Skip to content

Commit e4cb6fe

Browse files
committed
return an error if no httpClient is provided
Signed-off-by: Tim Ramlot <[email protected]>
1 parent 5db1738 commit e4cb6fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/client/apiutil/apimachinery.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func AddToProtobufScheme(addToScheme func(*runtime.Scheme) error) error {
6464
// information fetched by a new client with the given config.
6565
func NewDiscoveryRESTMapper(c *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
6666
if httpClient == nil {
67-
panic("httpClient must not be nil")
67+
return nil, fmt.Errorf("httpClient must not be nil")
6868
}
6969

7070
// Get a mapper
@@ -157,7 +157,7 @@ func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersi
157157
// baseConfig, if set, otherwise a default serializer will be set.
158158
func RESTClientForGVK(gvk schema.GroupVersionKind, isUnstructured bool, baseConfig *rest.Config, codecs serializer.CodecFactory, httpClient *http.Client) (rest.Interface, error) {
159159
if httpClient == nil {
160-
panic("httpClient must not be nil")
160+
return nil, fmt.Errorf("httpClient must not be nil")
161161
}
162162
return rest.RESTClientForConfigAndClient(createRestConfig(gvk, isUnstructured, baseConfig, codecs), httpClient)
163163
}

0 commit comments

Comments
 (0)