diff --git a/client/xnsinformer/factory.go b/client/xnsinformer/factory.go index 59b08c73..1965392a 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 } } @@ -84,7 +84,7 @@ func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Dur func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { factory := &sharedInformerFactory{ client: client, - namespaces: informers.NewNamespaceSet(), + namespaces: informers.NewNamespaceSet(v1.NamespaceAll), defaultResync: defaultResync, informers: make(map[reflect.Type]cache.SharedIndexInformer), startedInformers: make(map[reflect.Type]bool), @@ -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/core/v1/zz_generated.deepcopy.go b/core/v1/zz_generated.deepcopy.go index ee93f13b..e986ceab 100644 --- a/core/v1/zz_generated.deepcopy.go +++ b/core/v1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated // Copyright Red Hat, Inc. diff --git a/core/v1alpha1/conversion_generated.go b/core/v1alpha1/conversion_generated.go index 2387ae36..e48eed4f 100644 --- a/core/v1alpha1/conversion_generated.go +++ b/core/v1alpha1/conversion_generated.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated // Copyright Red Hat, Inc. diff --git a/core/v1alpha1/zz_generated.deepcopy.go b/core/v1alpha1/zz_generated.deepcopy.go index 70beb216..b4db054b 100644 --- a/core/v1alpha1/zz_generated.deepcopy.go +++ b/core/v1alpha1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated // Copyright Red Hat, Inc. diff --git a/core/v2/zz_generated.deepcopy.go b/core/v2/zz_generated.deepcopy.go index 5309b7cc..be50de1e 100644 --- a/core/v2/zz_generated.deepcopy.go +++ b/core/v2/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated // Copyright Red Hat, Inc. diff --git a/federation/v1/zz_generated.deepcopy.go b/federation/v1/zz_generated.deepcopy.go index ede9ebfc..2ebc8a63 100644 --- a/federation/v1/zz_generated.deepcopy.go +++ b/federation/v1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated // Copyright Red Hat, Inc. diff --git a/go.mod b/go.mod index 1f70a72f..70bf14c7 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.1 github.com/google/go-cmp v0.5.2 - github.com/maistra/xns-informer v0.0.0-20220920133259-f0b868f688e0 + github.com/maistra/xns-informer v0.0.0-20221007121715-3ae7b6592ef4 github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 google.golang.org/grpc v1.28.1 diff --git a/go.sum b/go.sum index 32975a1c..8ec23ee6 100644 --- a/go.sum +++ b/go.sum @@ -324,8 +324,8 @@ github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 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/maistra/xns-informer v0.0.0-20220920133259-f0b868f688e0 h1:RncQuyq1CZPFwnf8O/kAuQJFj1A4M1jwptfr0WHmuCw= -github.com/maistra/xns-informer v0.0.0-20220920133259-f0b868f688e0/go.mod h1:Bwe3VRiuXlSXu8MktDkmbrFcmSDysxuoOra542o0Ljk= +github.com/maistra/xns-informer v0.0.0-20221007121715-3ae7b6592ef4 h1:bmRcAmXcPdYK622r/XRyl9hxqhLpEcfJf7pws8SHWCw= +github.com/maistra/xns-informer v0.0.0-20221007121715-3ae7b6592ef4/go.mod h1:Bwe3VRiuXlSXu8MktDkmbrFcmSDysxuoOra542o0Ljk= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 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 d813b99d..1ae5a419 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -45,7 +45,7 @@ github.com/imdario/mergo github.com/inconshreveable/mousetrap # github.com/json-iterator/go v1.1.10 github.com/json-iterator/go -# github.com/maistra/xns-informer v0.0.0-20220920133259-f0b868f688e0 +# github.com/maistra/xns-informer v0.0.0-20221007121715-3ae7b6592ef4 ## explicit github.com/maistra/xns-informer/cmd/xns-informer-gen github.com/maistra/xns-informer/cmd/xns-informer-gen/args