diff --git a/client/xnsinformer/factory.go b/client/xnsinformer/factory.go index 59b08c73..9c399843 100644 --- a/client/xnsinformer/factory.go +++ b/client/xnsinformer/factory.go @@ -70,7 +70,7 @@ func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFu // WithNamespaces limits the SharedInformerFactory to the specified namespaces. func WithNamespaces(namespaces ...string) SharedInformerOption { return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.SetNamespaces(namespaces...) + factory.SetNamespaces(namespaces) return factory } } @@ -100,11 +100,11 @@ func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResy } // SetNamespaces updates the set of namespaces for all current and future informers. -func (f *sharedInformerFactory) SetNamespaces(namespaces ...string) { +func (f *sharedInformerFactory) SetNamespaces(namespaces []string) { f.lock.Lock() defer f.lock.Unlock() - f.namespaces.SetNamespaces(namespaces...) + f.namespaces.SetNamespaces(namespaces) } // Start initializes all requested informers. @@ -169,7 +169,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal // API group versions. type SharedInformerFactory interface { internalinterfaces.SharedInformerFactory - SetNamespaces(namespaces ...string) + SetNamespaces(namespaces []string) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool diff --git a/go.mod b/go.mod index c9a0cf85..22dcbea0 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/gogo/protobuf v1.3.2 github.com/google/go-cmp v0.5.6 - github.com/maistra/xns-informer v0.0.0-20220920101259-8467c347491a + github.com/maistra/xns-informer v0.0.0-20221007121714-8000c40e5493 github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 google.golang.org/grpc v1.42.0 diff --git a/go.sum b/go.sum index aff18800..cc9b0c3c 100644 --- a/go.sum +++ b/go.sum @@ -337,8 +337,8 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/maistra/xns-informer v0.0.0-20220920101259-8467c347491a h1:0eb/ZjoJgg7QjUMKy9nPbjztSiiYgH68ZblO2zqimw0= -github.com/maistra/xns-informer v0.0.0-20220920101259-8467c347491a/go.mod h1:0ZUF4kjow/MlN7Gp6OY7w2qBsWSG4MDBNxUp1VSSs/A= +github.com/maistra/xns-informer v0.0.0-20221007121714-8000c40e5493 h1:FxVGuZ8VKZ0prLPdr6iFIGtkRB3+R7MekFlpTLDwdyc= +github.com/maistra/xns-informer v0.0.0-20221007121714-8000c40e5493/go.mod h1:0ZUF4kjow/MlN7Gp6OY7w2qBsWSG4MDBNxUp1VSSs/A= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= diff --git a/vendor/github.com/maistra/xns-informer/cmd/xns-informer-gen/generators/factory.go b/vendor/github.com/maistra/xns-informer/cmd/xns-informer-gen/generators/factory.go index 6d28a3a3..02db8b33 100644 --- a/vendor/github.com/maistra/xns-informer/cmd/xns-informer-gen/generators/factory.go +++ b/vendor/github.com/maistra/xns-informer/cmd/xns-informer-gen/generators/factory.go @@ -140,7 +140,7 @@ func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFu // WithNamespaces limits the SharedInformerFactory to the specified namespaces. func WithNamespaces(namespaces ...string) SharedInformerOption { return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.SetNamespaces(namespaces...) + factory.SetNamespaces(namespaces) return factory } } @@ -154,7 +154,7 @@ func NewSharedInformerFactory(client {{.clientSetInterface|raw}}, defaultResync func NewSharedInformerFactoryWithOptions(client {{.clientSetInterface|raw}}, defaultResync {{.timeDuration|raw}}, options ...SharedInformerOption) SharedInformerFactory { factory := &sharedInformerFactory{ client: client, - namespaces: {{.xnsNewNamespaceSet|raw}}(), + namespaces: {{.xnsNewNamespaceSet|raw}}(v1.NamespaceAll), defaultResync: defaultResync, informers: make(map[{{.reflectType|raw}}]{{.cacheSharedIndexInformer|raw}}), startedInformers: make(map[{{.reflectType|raw}}]bool), @@ -170,11 +170,11 @@ func NewSharedInformerFactoryWithOptions(client {{.clientSetInterface|raw}}, def } // SetNamespaces updates the set of namespaces for all current and future informers. -func (f *sharedInformerFactory) SetNamespaces(namespaces ...string) { +func (f *sharedInformerFactory) SetNamespaces(namespaces []string) { f.lock.Lock() defer f.lock.Unlock() - f.namespaces.SetNamespaces(namespaces...) + f.namespaces.SetNamespaces(namespaces) } // Start initializes all requested informers. @@ -242,7 +242,7 @@ var sharedInformerFactoryInterface = ` // API group versions. type SharedInformerFactory interface { {{.informerFactoryInterface|raw}} - SetNamespaces(namespaces ...string) + SetNamespaces(namespaces []string) ForResource(resource {{.schemaGroupVersionResource|raw}}) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool diff --git a/vendor/github.com/maistra/xns-informer/pkg/informers/dynamic.go b/vendor/github.com/maistra/xns-informer/pkg/informers/dynamic.go index 008ffe6e..90a434e3 100644 --- a/vendor/github.com/maistra/xns-informer/pkg/informers/dynamic.go +++ b/vendor/github.com/maistra/xns-informer/pkg/informers/dynamic.go @@ -22,14 +22,14 @@ import ( // namespaces, it will not work for cluster-scoped resources. type DynamicSharedInformerFactory interface { Start(stopCh <-chan struct{}) - SetNamespaces(namespaces ...string) + SetNamespaces(namespaces []string) ForResource(gvr schema.GroupVersionResource) informers.GenericInformer WaitForCacheSync(stopCh <-chan struct{}) map[schema.GroupVersionResource]bool } // NewDynamicSharedInformerFactory constructs a new instance of dynamicSharedInformerFactory for all namespaces. func NewDynamicSharedInformerFactory(client dynamic.Interface, defaultResync time.Duration) DynamicSharedInformerFactory { - namespaces := NewNamespaceSet() + namespaces := NewNamespaceSet(metav1.NamespaceAll) return NewFilteredDynamicSharedInformerFactory(client, defaultResync, namespaces, nil) } @@ -86,11 +86,11 @@ func (f *dynamicSharedInformerFactory) ForResource(gvr schema.GroupVersionResour } // SetNamespaces updates the set of namespaces for all current and future informers. -func (f *dynamicSharedInformerFactory) SetNamespaces(namespaces ...string) { +func (f *dynamicSharedInformerFactory) SetNamespaces(namespaces []string) { f.lock.Lock() defer f.lock.Unlock() - f.namespaces.SetNamespaces(namespaces...) + f.namespaces.SetNamespaces(namespaces) } // Start initializes all requested informers. diff --git a/vendor/github.com/maistra/xns-informer/pkg/informers/metadata.go b/vendor/github.com/maistra/xns-informer/pkg/informers/metadata.go index c87f5d61..8925f5dc 100644 --- a/vendor/github.com/maistra/xns-informer/pkg/informers/metadata.go +++ b/vendor/github.com/maistra/xns-informer/pkg/informers/metadata.go @@ -18,14 +18,14 @@ import ( // MetadataSharedInformerFactory provides access to shared informers and listers for metadata client. type MetadataSharedInformerFactory interface { Start(stopCh <-chan struct{}) - SetNamespaces(namespaces ...string) + SetNamespaces(namespaces []string) ForResource(gvr schema.GroupVersionResource) informers.GenericInformer WaitForCacheSync(stopCh <-chan struct{}) map[schema.GroupVersionResource]bool } // NewMetadataSharedInformerFactory constructs a new instance of metadataSharedInformerFactory for all namespaces. func NewMetadataSharedInformerFactory(client metadata.Interface, defaultResync time.Duration) MetadataSharedInformerFactory { - namespaces := NewNamespaceSet() + namespaces := NewNamespaceSet(metav1.NamespaceAll) return NewFilteredMetadataSharedInformerFactory(client, defaultResync, namespaces, nil) } @@ -74,11 +74,11 @@ func (f *metadataSharedInformerFactory) ForResource(gvr schema.GroupVersionResou } // SetNamespaces updates the set of namespaces for all current and future informers. -func (f *metadataSharedInformerFactory) SetNamespaces(namespaces ...string) { +func (f *metadataSharedInformerFactory) SetNamespaces(namespaces []string) { f.lock.Lock() defer f.lock.Unlock() - f.namespaces.SetNamespaces(namespaces...) + f.namespaces.SetNamespaces(namespaces) } // Start initializes all requested informers. diff --git a/vendor/github.com/maistra/xns-informer/pkg/informers/namespace_set.go b/vendor/github.com/maistra/xns-informer/pkg/informers/namespace_set.go index 01002afa..8174aea6 100644 --- a/vendor/github.com/maistra/xns-informer/pkg/informers/namespace_set.go +++ b/vendor/github.com/maistra/xns-informer/pkg/informers/namespace_set.go @@ -42,22 +42,30 @@ func (h NamespaceSetHandlerFuncs) OnRemove(namespace string) { type NamespaceSet interface { // Initialized returns true if SetNamespaces() has been called at least once Initialized() bool - SetNamespaces(namespaces ...string) + SetNamespaces(namespaces []string) AddHandler(handler NamespaceSetHandler) Contains(namespace string) bool List() []string } type namespaceSet struct { - initialized bool - lock sync.Mutex - namespaces sets.Set - handlers []NamespaceSetHandler + lock sync.Mutex + namespaces sets.Set + handlers []NamespaceSetHandler } -// NewNamespaceSet returns a new NamespaceSet. -func NewNamespaceSet() NamespaceSet { - return &namespaceSet{} +// NewNamespaceSet returns a new NamespaceSet tracking the given namespaces. +func NewNamespaceSet(namespaces ...string) NamespaceSet { + n := &namespaceSet{} + n.SetNamespaces(namespaces) + + return n +} + +// NewUninitializedNamespaceSet returns a new uninitialized NamespaceSet +func NewUninitializedNamespaceSet() NamespaceSet { + n := &namespaceSet{} + return n } // Contains indicates whether the given namespace is in the set. @@ -83,20 +91,21 @@ func (n *namespaceSet) Initialized() bool { n.lock.Lock() defer n.lock.Unlock() - return n.initialized + return n.namespaces != nil } // SetNamespaces replaces the set of namespaces. -func (n *namespaceSet) SetNamespaces(namespaces ...string) { +func (n *namespaceSet) SetNamespaces(namespaces []string) { n.lock.Lock() defer n.lock.Unlock() - if !n.initialized { - n.initialized = true + var newNamespaceSet sets.Set + if namespaces == nil { + newNamespaceSet = nil + } else { + newNamespaceSet = sets.NewSet(namespaces...) } - newNamespaceSet := sets.NewSet(namespaces...) - // If the set of namespaces, includes metav1.NamespaceAll, then it // only makes sense to track that. if newNamespaceSet.Contains(metav1.NamespaceAll) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 62eda0a2..1f8456f5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -41,7 +41,7 @@ github.com/imdario/mergo github.com/inconshreveable/mousetrap # github.com/json-iterator/go v1.1.11 github.com/json-iterator/go -# github.com/maistra/xns-informer v0.0.0-20220920101259-8467c347491a +# github.com/maistra/xns-informer v0.0.0-20221007121714-8000c40e5493 ## explicit github.com/maistra/xns-informer/cmd/xns-informer-gen github.com/maistra/xns-informer/cmd/xns-informer-gen/args