Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit fc82a71

Browse files
author
James Munnelly
committed
Regenerate files
1 parent 3dc6cc5 commit fc82a71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2570
-32
lines changed

pkg/client/informers/externalversions/factory.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
type sharedInformerFactory struct {
3434
client versioned.Interface
35+
filter internalinterfaces.FilterFunc
3536
lock sync.Mutex
3637
defaultResync time.Duration
3738

@@ -43,8 +44,14 @@ type sharedInformerFactory struct {
4344

4445
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
4546
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
47+
return NewFilteredSharedInformerFactory(client, defaultResync, internalinterfaces.DefaultFilterFunc)
48+
}
49+
50+
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory
51+
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, filter internalinterfaces.FilterFunc) SharedInformerFactory {
4652
return &sharedInformerFactory{
4753
client: client,
54+
filter: filter,
4855
defaultResync: defaultResync,
4956
informers: make(map[reflect.Type]cache.SharedIndexInformer),
5057
startedInformers: make(map[reflect.Type]bool),
@@ -114,5 +121,5 @@ type SharedInformerFactory interface {
114121
}
115122

116123
func (f *sharedInformerFactory) Navigator() navigator.Interface {
117-
return navigator.New(f)
124+
return navigator.New(f, f.filter)
118125
}

pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package internalinterfaces
2020

2121
import (
2222
versioned "github.com/jetstack/navigator/pkg/client/clientset/versioned"
23+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
runtime "k8s.io/apimachinery/pkg/runtime"
2425
cache "k8s.io/client-go/tools/cache"
2526
time "time"
@@ -32,3 +33,15 @@ type SharedInformerFactory interface {
3233
Start(stopCh <-chan struct{})
3334
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
3435
}
36+
37+
type FilterFunc func(*v1.ListOptions) (namespace string)
38+
39+
func DefaultFilterFunc(*v1.ListOptions) (namespace string) {
40+
return v1.NamespaceAll
41+
}
42+
43+
func NamespaceFilter(namespace string) FilterFunc {
44+
return func(*v1.ListOptions) string {
45+
return namespace
46+
}
47+
}

pkg/client/informers/externalversions/navigator/interface.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ type Interface interface {
3030
}
3131

3232
type group struct {
33-
internalinterfaces.SharedInformerFactory
33+
factory internalinterfaces.SharedInformerFactory
34+
filter internalinterfaces.FilterFunc
3435
}
3536

3637
// New returns a new Interface.
37-
func New(f internalinterfaces.SharedInformerFactory) Interface {
38-
return &group{f}
38+
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
39+
return &group{factory: f, filter: filter}
3940
}
4041

4142
// V1alpha1 returns a new v1alpha1.Interface.
4243
func (g *group) V1alpha1() v1alpha1.Interface {
43-
return v1alpha1.New(g.SharedInformerFactory)
44+
return v1alpha1.New(g.factory, g.filter)
4445
}

pkg/client/informers/externalversions/navigator/v1alpha1/elasticsearchcluster.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,29 @@ type ElasticsearchClusterInformer interface {
3939

4040
type elasticsearchClusterInformer struct {
4141
factory internalinterfaces.SharedInformerFactory
42+
filter internalinterfaces.FilterFunc
4243
}
4344

4445
// NewElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
4546
// Always prefer using an informer factory to get a shared informer instead of getting an independent
4647
// one. This reduces memory footprint and number of connections to the server.
4748
func NewElasticsearchClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
49+
filter := internalinterfaces.NamespaceFilter(namespace)
50+
return NewFilteredElasticsearchClusterInformer(client, filter, resyncPeriod, indexers)
51+
}
52+
53+
// NewFilteredElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
54+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
55+
// one. This reduces memory footprint and number of connections to the server.
56+
func NewFilteredElasticsearchClusterInformer(client versioned.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
4857
return cache.NewSharedIndexInformer(
4958
&cache.ListWatch{
5059
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
60+
namespace := filter(&options)
5161
return client.NavigatorV1alpha1().ElasticsearchClusters(namespace).List(options)
5262
},
5363
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
64+
namespace := filter(&options)
5465
return client.NavigatorV1alpha1().ElasticsearchClusters(namespace).Watch(options)
5566
},
5667
},
@@ -60,12 +71,12 @@ func NewElasticsearchClusterInformer(client versioned.Interface, namespace strin
6071
)
6172
}
6273

63-
func defaultElasticsearchClusterInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
64-
return NewElasticsearchClusterInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
74+
func (f *elasticsearchClusterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
75+
return NewFilteredElasticsearchClusterInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
6576
}
6677

6778
func (f *elasticsearchClusterInformer) Informer() cache.SharedIndexInformer {
68-
return f.factory.InformerFor(&navigator_v1alpha1.ElasticsearchCluster{}, defaultElasticsearchClusterInformer)
79+
return f.factory.InformerFor(&navigator_v1alpha1.ElasticsearchCluster{}, f.defaultInformer)
6980
}
7081

7182
func (f *elasticsearchClusterInformer) Lister() v1alpha1.ElasticsearchClusterLister {

pkg/client/informers/externalversions/navigator/v1alpha1/interface.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ type Interface interface {
3131
}
3232

3333
type version struct {
34-
internalinterfaces.SharedInformerFactory
34+
factory internalinterfaces.SharedInformerFactory
35+
filter internalinterfaces.FilterFunc
3536
}
3637

3738
// New returns a new Interface.
38-
func New(f internalinterfaces.SharedInformerFactory) Interface {
39-
return &version{f}
39+
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
40+
return &version{factory: f, filter: filter}
4041
}
4142

4243
// ElasticsearchClusters returns a ElasticsearchClusterInformer.
4344
func (v *version) ElasticsearchClusters() ElasticsearchClusterInformer {
44-
return &elasticsearchClusterInformer{factory: v.SharedInformerFactory}
45+
return &elasticsearchClusterInformer{factory: v.factory, filter: v.filter}
4546
}
4647

4748
// Pilots returns a PilotInformer.
4849
func (v *version) Pilots() PilotInformer {
49-
return &pilotInformer{factory: v.SharedInformerFactory}
50+
return &pilotInformer{factory: v.factory, filter: v.filter}
5051
}

pkg/client/informers/externalversions/navigator/v1alpha1/pilot.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,29 @@ type PilotInformer interface {
3939

4040
type pilotInformer struct {
4141
factory internalinterfaces.SharedInformerFactory
42+
filter internalinterfaces.FilterFunc
4243
}
4344

4445
// NewPilotInformer constructs a new informer for Pilot type.
4546
// Always prefer using an informer factory to get a shared informer instead of getting an independent
4647
// one. This reduces memory footprint and number of connections to the server.
4748
func NewPilotInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
49+
filter := internalinterfaces.NamespaceFilter(namespace)
50+
return NewFilteredPilotInformer(client, filter, resyncPeriod, indexers)
51+
}
52+
53+
// NewFilteredPilotInformer constructs a new informer for Pilot type.
54+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
55+
// one. This reduces memory footprint and number of connections to the server.
56+
func NewFilteredPilotInformer(client versioned.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
4857
return cache.NewSharedIndexInformer(
4958
&cache.ListWatch{
5059
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
60+
namespace := filter(&options)
5161
return client.NavigatorV1alpha1().Pilots(namespace).List(options)
5262
},
5363
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
64+
namespace := filter(&options)
5465
return client.NavigatorV1alpha1().Pilots(namespace).Watch(options)
5566
},
5667
},
@@ -60,12 +71,12 @@ func NewPilotInformer(client versioned.Interface, namespace string, resyncPeriod
6071
)
6172
}
6273

63-
func defaultPilotInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
64-
return NewPilotInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
74+
func (f *pilotInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
75+
return NewFilteredPilotInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
6576
}
6677

6778
func (f *pilotInformer) Informer() cache.SharedIndexInformer {
68-
return f.factory.InformerFor(&navigator_v1alpha1.Pilot{}, defaultPilotInformer)
79+
return f.factory.InformerFor(&navigator_v1alpha1.Pilot{}, f.defaultInformer)
6980
}
7081

7182
func (f *pilotInformer) Lister() v1alpha1.PilotLister {

pkg/client/informers/internalversion/factory.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
type sharedInformerFactory struct {
3434
client internalversion.Interface
35+
filter internalinterfaces.FilterFunc
3536
lock sync.Mutex
3637
defaultResync time.Duration
3738

@@ -43,8 +44,14 @@ type sharedInformerFactory struct {
4344

4445
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
4546
func NewSharedInformerFactory(client internalversion.Interface, defaultResync time.Duration) SharedInformerFactory {
47+
return NewFilteredSharedInformerFactory(client, defaultResync, internalinterfaces.DefaultFilterFunc)
48+
}
49+
50+
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory
51+
func NewFilteredSharedInformerFactory(client internalversion.Interface, defaultResync time.Duration, filter internalinterfaces.FilterFunc) SharedInformerFactory {
4652
return &sharedInformerFactory{
4753
client: client,
54+
filter: filter,
4855
defaultResync: defaultResync,
4956
informers: make(map[reflect.Type]cache.SharedIndexInformer),
5057
startedInformers: make(map[reflect.Type]bool),
@@ -114,5 +121,5 @@ type SharedInformerFactory interface {
114121
}
115122

116123
func (f *sharedInformerFactory) Navigator() navigator.Interface {
117-
return navigator.New(f)
124+
return navigator.New(f, f.filter)
118125
}

pkg/client/informers/internalversion/internalinterfaces/factory_interfaces.go

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package internalinterfaces
2020

2121
import (
2222
internalversion "github.com/jetstack/navigator/pkg/client/clientset/internalversion"
23+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
runtime "k8s.io/apimachinery/pkg/runtime"
2425
cache "k8s.io/client-go/tools/cache"
2526
time "time"
@@ -32,3 +33,15 @@ type SharedInformerFactory interface {
3233
Start(stopCh <-chan struct{})
3334
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
3435
}
36+
37+
type FilterFunc func(*v1.ListOptions) (namespace string)
38+
39+
func DefaultFilterFunc(*v1.ListOptions) (namespace string) {
40+
return v1.NamespaceAll
41+
}
42+
43+
func NamespaceFilter(namespace string) FilterFunc {
44+
return func(*v1.ListOptions) string {
45+
return namespace
46+
}
47+
}

pkg/client/informers/internalversion/navigator/interface.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ type Interface interface {
3030
}
3131

3232
type group struct {
33-
internalinterfaces.SharedInformerFactory
33+
factory internalinterfaces.SharedInformerFactory
34+
filter internalinterfaces.FilterFunc
3435
}
3536

3637
// New returns a new Interface.
37-
func New(f internalinterfaces.SharedInformerFactory) Interface {
38-
return &group{f}
38+
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
39+
return &group{factory: f, filter: filter}
3940
}
4041

4142
// InternalVersion returns a new internalversion.Interface.
4243
func (g *group) InternalVersion() internalversion.Interface {
43-
return internalversion.New(g.SharedInformerFactory)
44+
return internalversion.New(g.factory, g.filter)
4445
}

pkg/client/informers/internalversion/navigator/internalversion/elasticsearchcluster.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,29 @@ type ElasticsearchClusterInformer interface {
3939

4040
type elasticsearchClusterInformer struct {
4141
factory internalinterfaces.SharedInformerFactory
42+
filter internalinterfaces.FilterFunc
4243
}
4344

4445
// NewElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
4546
// Always prefer using an informer factory to get a shared informer instead of getting an independent
4647
// one. This reduces memory footprint and number of connections to the server.
4748
func NewElasticsearchClusterInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
49+
filter := internalinterfaces.NamespaceFilter(namespace)
50+
return NewFilteredElasticsearchClusterInformer(client, filter, resyncPeriod, indexers)
51+
}
52+
53+
// NewFilteredElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
54+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
55+
// one. This reduces memory footprint and number of connections to the server.
56+
func NewFilteredElasticsearchClusterInformer(client clientset_internalversion.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
4857
return cache.NewSharedIndexInformer(
4958
&cache.ListWatch{
5059
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
60+
namespace := filter(&options)
5161
return client.Navigator().ElasticsearchClusters(namespace).List(options)
5262
},
5363
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
64+
namespace := filter(&options)
5465
return client.Navigator().ElasticsearchClusters(namespace).Watch(options)
5566
},
5667
},
@@ -60,12 +71,12 @@ func NewElasticsearchClusterInformer(client clientset_internalversion.Interface,
6071
)
6172
}
6273

63-
func defaultElasticsearchClusterInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
64-
return NewElasticsearchClusterInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
74+
func (f *elasticsearchClusterInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
75+
return NewFilteredElasticsearchClusterInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
6576
}
6677

6778
func (f *elasticsearchClusterInformer) Informer() cache.SharedIndexInformer {
68-
return f.factory.InformerFor(&navigator.ElasticsearchCluster{}, defaultElasticsearchClusterInformer)
79+
return f.factory.InformerFor(&navigator.ElasticsearchCluster{}, f.defaultInformer)
6980
}
7081

7182
func (f *elasticsearchClusterInformer) Lister() internalversion.ElasticsearchClusterLister {

pkg/client/informers/internalversion/navigator/internalversion/interface.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ type Interface interface {
3131
}
3232

3333
type version struct {
34-
internalinterfaces.SharedInformerFactory
34+
factory internalinterfaces.SharedInformerFactory
35+
filter internalinterfaces.FilterFunc
3536
}
3637

3738
// New returns a new Interface.
38-
func New(f internalinterfaces.SharedInformerFactory) Interface {
39-
return &version{f}
39+
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
40+
return &version{factory: f, filter: filter}
4041
}
4142

4243
// ElasticsearchClusters returns a ElasticsearchClusterInformer.
4344
func (v *version) ElasticsearchClusters() ElasticsearchClusterInformer {
44-
return &elasticsearchClusterInformer{factory: v.SharedInformerFactory}
45+
return &elasticsearchClusterInformer{factory: v.factory, filter: v.filter}
4546
}
4647

4748
// Pilots returns a PilotInformer.
4849
func (v *version) Pilots() PilotInformer {
49-
return &pilotInformer{factory: v.SharedInformerFactory}
50+
return &pilotInformer{factory: v.factory, filter: v.filter}
5051
}

pkg/client/informers/internalversion/navigator/internalversion/pilot.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,29 @@ type PilotInformer interface {
3939

4040
type pilotInformer struct {
4141
factory internalinterfaces.SharedInformerFactory
42+
filter internalinterfaces.FilterFunc
4243
}
4344

4445
// NewPilotInformer constructs a new informer for Pilot type.
4546
// Always prefer using an informer factory to get a shared informer instead of getting an independent
4647
// one. This reduces memory footprint and number of connections to the server.
4748
func NewPilotInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
49+
filter := internalinterfaces.NamespaceFilter(namespace)
50+
return NewFilteredPilotInformer(client, filter, resyncPeriod, indexers)
51+
}
52+
53+
// NewFilteredPilotInformer constructs a new informer for Pilot type.
54+
// Always prefer using an informer factory to get a shared informer instead of getting an independent
55+
// one. This reduces memory footprint and number of connections to the server.
56+
func NewFilteredPilotInformer(client clientset_internalversion.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
4857
return cache.NewSharedIndexInformer(
4958
&cache.ListWatch{
5059
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
60+
namespace := filter(&options)
5161
return client.Navigator().Pilots(namespace).List(options)
5262
},
5363
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
64+
namespace := filter(&options)
5465
return client.Navigator().Pilots(namespace).Watch(options)
5566
},
5667
},
@@ -60,12 +71,12 @@ func NewPilotInformer(client clientset_internalversion.Interface, namespace stri
6071
)
6172
}
6273

63-
func defaultPilotInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
64-
return NewPilotInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
74+
func (f *pilotInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
75+
return NewFilteredPilotInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
6576
}
6677

6778
func (f *pilotInformer) Informer() cache.SharedIndexInformer {
68-
return f.factory.InformerFor(&navigator.Pilot{}, defaultPilotInformer)
79+
return f.factory.InformerFor(&navigator.Pilot{}, f.defaultInformer)
6980
}
7081

7182
func (f *pilotInformer) Lister() internalversion.PilotLister {

0 commit comments

Comments
 (0)