1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-10 03:29:14 +00:00

Add timeouts to rest clients

This commit is contained in:
Darren Shepherd
2018-04-02 15:45:10 -07:00
parent 9f2b71df50
commit 510ed570d2
4 changed files with 57 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"github.com/pkg/errors"
"github.com/rancher/norman/restwatch"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -199,7 +200,12 @@ func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
}
func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
r, err := p.restClient.Get().
restClient := p.restClient
if watchClient, ok := restClient.(restwatch.WatchClient); ok {
restClient = watchClient.WatchClient()
}
r, err := restClient.Get().
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
Prefix("watch").
NamespaceIfScoped(p.ns, p.resource.Namespaced).