diff --git a/vendor.conf b/vendor.conf index 5a7b0a74..6a45ccc0 100644 --- a/vendor.conf +++ b/vendor.conf @@ -5,4 +5,4 @@ k8s.io/kubernetes v1.8.3 bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5 -github.com/rancher/norman 9f2b71df502fc476603eed99d137593d4a879f53 +github.com/rancher/norman 510ed570d2e29a00e6bc1bcd18bdcad6c6860a13 diff --git a/vendor/github.com/rancher/norman/clientbase/object_client.go b/vendor/github.com/rancher/norman/clientbase/object_client.go index 9969bfb1..19102f2d 100644 --- a/vendor/github.com/rancher/norman/clientbase/object_client.go +++ b/vendor/github.com/rancher/norman/clientbase/object_client.go @@ -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). diff --git a/vendor/github.com/rancher/norman/generator/k8s_client_template.go b/vendor/github.com/rancher/norman/generator/k8s_client_template.go index 0a22571e..0e4f1290 100644 --- a/vendor/github.com/rancher/norman/generator/k8s_client_template.go +++ b/vendor/github.com/rancher/norman/generator/k8s_client_template.go @@ -8,6 +8,7 @@ import ( "github.com/rancher/norman/clientbase" "github.com/rancher/norman/controller" + "github.com/rancher/norman/restwatch" "k8s.io/client-go/dynamic" "k8s.io/client-go/rest" ) @@ -33,7 +34,7 @@ func NewForConfig(config rest.Config) (Interface, error) { config.NegotiatedSerializer = configConfig.NegotiatedSerializer } - restClient, err := rest.UnversionedRESTClientFor(&config) + restClient, err := restwatch.UnversionedRESTClientFor(&config) if err != nil { return nil, err } diff --git a/vendor/github.com/rancher/norman/restwatch/rest.go b/vendor/github.com/rancher/norman/restwatch/rest.go new file mode 100644 index 00000000..25092052 --- /dev/null +++ b/vendor/github.com/rancher/norman/restwatch/rest.go @@ -0,0 +1,43 @@ +package restwatch + +import ( + "time" + + "k8s.io/client-go/rest" +) + +type WatchClient interface { + WatchClient() rest.Interface +} + +func UnversionedRESTClientFor(config *rest.Config) (rest.Interface, error) { + client, err := rest.UnversionedRESTClientFor(config) + if err != nil { + return nil, err + } + + if config.Timeout == 0 { + return client, err + } + + newConfig := *config + newConfig.Timeout = time.Hour + watchClient, err := rest.UnversionedRESTClientFor(&newConfig) + if err != nil { + return nil, err + } + + return &clientWithWatch{ + RESTClient: client, + watchClient: watchClient, + }, nil +} + +type clientWithWatch struct { + *rest.RESTClient + watchClient *rest.RESTClient +} + +func (c *clientWithWatch) WatchClient() rest.Interface { + return c.watchClient +} diff --git a/vendor/github.com/rancher/norman/store/proxy/proxy_store.go b/vendor/github.com/rancher/norman/store/proxy/proxy_store.go index f38cac45..be8388e2 100644 --- a/vendor/github.com/rancher/norman/store/proxy/proxy_store.go +++ b/vendor/github.com/rancher/norman/store/proxy/proxy_store.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/rancher/norman/restwatch" "github.com/rancher/norman/types" "github.com/rancher/norman/types/convert" "github.com/rancher/norman/types/values" @@ -187,6 +188,10 @@ func (p *Store) Watch(apiContext *types.APIContext, schema *types.Schema, opt *t return nil, err } + if watchClient, ok := k8sClient.(restwatch.WatchClient); ok { + k8sClient = watchClient.WatchClient() + } + timeout := int64(60 * 60) req := p.common(namespace, k8sClient.Get()) req.VersionedParams(&metav1.ListOptions{