1
0
mirror of https://github.com/rancher/types.git synced 2025-08-02 05:11:59 +00:00

Update vendor

This commit is contained in:
Darren Shepherd 2018-04-02 15:49:46 -07:00
parent c55b0446a3
commit d27b2a4708
5 changed files with 58 additions and 3 deletions

View File

@ -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

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).

View File

@ -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
}

43
vendor/github.com/rancher/norman/restwatch/rest.go generated vendored Normal file
View File

@ -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
}

View File

@ -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{