diff --git a/vendor.conf b/vendor.conf index 6d972480..13eac406 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 722cedfe014fbfe9f1e5572b5582960f7eb3a2fb +github.com/rancher/norman c814e62e436aeaeaf51ae3da439e520068494a7b diff --git a/vendor/github.com/rancher/norman/clientbase/object_client.go b/vendor/github.com/rancher/norman/clientbase/object_client.go index e68f14d0..4e1f8efb 100644 --- a/vendor/github.com/rancher/norman/clientbase/object_client.go +++ b/vendor/github.com/rancher/norman/clientbase/object_client.go @@ -31,6 +31,22 @@ func (u *UnstructuredObjectFactory) List() runtime.Object { return &unstructured.UnstructuredList{} } +type GenericClient interface { + UnstructuredClient() GenericClient + GroupVersionKind() schema.GroupVersionKind + Create(o runtime.Object) (runtime.Object, error) + GetNamespaced(namespace, name string, opts metav1.GetOptions) (runtime.Object, error) + Get(name string, opts metav1.GetOptions) (runtime.Object, error) + Update(name string, o runtime.Object) (runtime.Object, error) + DeleteNamespaced(namespace, name string, opts *metav1.DeleteOptions) error + Delete(name string, opts *metav1.DeleteOptions) error + List(opts metav1.ListOptions) (runtime.Object, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + DeleteCollection(deleteOptions *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Patch(name string, o runtime.Object, data []byte, subresources ...string) (runtime.Object, error) + ObjectFactory() ObjectFactory +} + type ObjectClient struct { restClient rest.Interface resource *metav1.APIResource @@ -49,7 +65,7 @@ func NewObjectClient(namespace string, restClient rest.Interface, apiResource *m } } -func (p *ObjectClient) UnstructuredClient() *ObjectClient { +func (p *ObjectClient) UnstructuredClient() GenericClient { return &ObjectClient{ restClient: p.restClient, resource: p.resource, @@ -230,6 +246,10 @@ func (p *ObjectClient) Patch(name string, o runtime.Object, data []byte, subreso return result, err } +func (p *ObjectClient) ObjectFactory() ObjectFactory { + return p.Factory +} + type dynamicDecoder struct { factory ObjectFactory dec *json.Decoder diff --git a/vendor/github.com/rancher/norman/controller/generic_controller.go b/vendor/github.com/rancher/norman/controller/generic_controller.go index 265db517..93b455d1 100644 --- a/vendor/github.com/rancher/norman/controller/generic_controller.go +++ b/vendor/github.com/rancher/norman/controller/generic_controller.go @@ -10,8 +10,11 @@ import ( "github.com/rancher/norman/clientbase" "github.com/rancher/norman/types" "github.com/sirupsen/logrus" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/tools/cache" "k8s.io/client-go/util/workqueue" ) @@ -31,6 +34,12 @@ type GenericController interface { Start(ctx context.Context, threadiness int) error } +type Backend interface { + List(opts metav1.ListOptions) (runtime.Object, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + ObjectFactory() clientbase.ObjectFactory +} + type handlerDef struct { name string handler HandlerFunc @@ -46,13 +55,13 @@ type genericController struct { synced bool } -func NewGenericController(name string, objectClient *clientbase.ObjectClient) GenericController { +func NewGenericController(name string, genericClient Backend) GenericController { informer := cache.NewSharedIndexInformer( &cache.ListWatch{ - ListFunc: objectClient.List, - WatchFunc: objectClient.Watch, + ListFunc: genericClient.List, + WatchFunc: genericClient.Watch, }, - objectClient.Factory.Object(), resyncPeriod, cache.Indexers{}) + genericClient.ObjectFactory().Object(), resyncPeriod, cache.Indexers{}) rl := workqueue.NewMaxOfRateLimiter( workqueue.NewItemExponentialFailureRateLimiter(500*time.Millisecond, 1000*time.Second), diff --git a/vendor/github.com/rancher/norman/types/reflection.go b/vendor/github.com/rancher/norman/types/reflection.go index c2e8bb9a..d8661d01 100644 --- a/vendor/github.com/rancher/norman/types/reflection.go +++ b/vendor/github.com/rancher/norman/types/reflection.go @@ -267,6 +267,9 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error { if fieldType.Kind() == reflect.Ptr { schemaField.Nullable = true fieldType = fieldType.Elem() + } else if fieldType.Kind() == reflect.Bool { + schemaField.Nullable = false + schemaField.Default = false } if err := applyTag(&field, &schemaField); err != nil {