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

Commit

Permalink
Regenerate files
Browse files Browse the repository at this point in the history
  • Loading branch information
munnerz committed Oct 31, 2017
1 parent 3dc6cc5 commit fc82a71
Show file tree
Hide file tree
Showing 41 changed files with 2,570 additions and 32 deletions.
9 changes: 8 additions & 1 deletion pkg/client/informers/externalversions/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

type sharedInformerFactory struct {
client versioned.Interface
filter internalinterfaces.FilterFunc
lock sync.Mutex
defaultResync time.Duration

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

// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewFilteredSharedInformerFactory(client, defaultResync, internalinterfaces.DefaultFilterFunc)
}

// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, filter internalinterfaces.FilterFunc) SharedInformerFactory {
return &sharedInformerFactory{
client: client,
filter: filter,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
Expand Down Expand Up @@ -114,5 +121,5 @@ type SharedInformerFactory interface {
}

func (f *sharedInformerFactory) Navigator() navigator.Interface {
return navigator.New(f)
return navigator.New(f, f.filter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package internalinterfaces

import (
versioned "github.com/jetstack/navigator/pkg/client/clientset/versioned"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
time "time"
Expand All @@ -32,3 +33,15 @@ type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}

type FilterFunc func(*v1.ListOptions) (namespace string)

func DefaultFilterFunc(*v1.ListOptions) (namespace string) {
return v1.NamespaceAll
}

func NamespaceFilter(namespace string) FilterFunc {
return func(*v1.ListOptions) string {
return namespace
}
}
9 changes: 5 additions & 4 deletions pkg/client/informers/externalversions/navigator/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ type Interface interface {
}

type group struct {
internalinterfaces.SharedInformerFactory
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &group{f}
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
return &group{factory: f, filter: filter}
}

// V1alpha1 returns a new v1alpha1.Interface.
func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.SharedInformerFactory)
return v1alpha1.New(g.factory, g.filter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,29 @@ type ElasticsearchClusterInformer interface {

type elasticsearchClusterInformer struct {
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// NewElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewElasticsearchClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
filter := internalinterfaces.NamespaceFilter(namespace)
return NewFilteredElasticsearchClusterInformer(client, filter, resyncPeriod, indexers)
}

// NewFilteredElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredElasticsearchClusterInformer(client versioned.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
namespace := filter(&options)
return client.NavigatorV1alpha1().ElasticsearchClusters(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
namespace := filter(&options)
return client.NavigatorV1alpha1().ElasticsearchClusters(namespace).Watch(options)
},
},
Expand All @@ -60,12 +71,12 @@ func NewElasticsearchClusterInformer(client versioned.Interface, namespace strin
)
}

func defaultElasticsearchClusterInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewElasticsearchClusterInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
func (f *elasticsearchClusterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredElasticsearchClusterInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
}

func (f *elasticsearchClusterInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&navigator_v1alpha1.ElasticsearchCluster{}, defaultElasticsearchClusterInformer)
return f.factory.InformerFor(&navigator_v1alpha1.ElasticsearchCluster{}, f.defaultInformer)
}

func (f *elasticsearchClusterInformer) Lister() v1alpha1.ElasticsearchClusterLister {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ type Interface interface {
}

type version struct {
internalinterfaces.SharedInformerFactory
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f}
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
return &version{factory: f, filter: filter}
}

// ElasticsearchClusters returns a ElasticsearchClusterInformer.
func (v *version) ElasticsearchClusters() ElasticsearchClusterInformer {
return &elasticsearchClusterInformer{factory: v.SharedInformerFactory}
return &elasticsearchClusterInformer{factory: v.factory, filter: v.filter}
}

// Pilots returns a PilotInformer.
func (v *version) Pilots() PilotInformer {
return &pilotInformer{factory: v.SharedInformerFactory}
return &pilotInformer{factory: v.factory, filter: v.filter}
}
17 changes: 14 additions & 3 deletions pkg/client/informers/externalversions/navigator/v1alpha1/pilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,29 @@ type PilotInformer interface {

type pilotInformer struct {
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// NewPilotInformer constructs a new informer for Pilot type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewPilotInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
filter := internalinterfaces.NamespaceFilter(namespace)
return NewFilteredPilotInformer(client, filter, resyncPeriod, indexers)
}

// NewFilteredPilotInformer constructs a new informer for Pilot type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredPilotInformer(client versioned.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
namespace := filter(&options)
return client.NavigatorV1alpha1().Pilots(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
namespace := filter(&options)
return client.NavigatorV1alpha1().Pilots(namespace).Watch(options)
},
},
Expand All @@ -60,12 +71,12 @@ func NewPilotInformer(client versioned.Interface, namespace string, resyncPeriod
)
}

func defaultPilotInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewPilotInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
func (f *pilotInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredPilotInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
}

func (f *pilotInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&navigator_v1alpha1.Pilot{}, defaultPilotInformer)
return f.factory.InformerFor(&navigator_v1alpha1.Pilot{}, f.defaultInformer)
}

func (f *pilotInformer) Lister() v1alpha1.PilotLister {
Expand Down
9 changes: 8 additions & 1 deletion pkg/client/informers/internalversion/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

type sharedInformerFactory struct {
client internalversion.Interface
filter internalinterfaces.FilterFunc
lock sync.Mutex
defaultResync time.Duration

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

// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(client internalversion.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewFilteredSharedInformerFactory(client, defaultResync, internalinterfaces.DefaultFilterFunc)
}

// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewFilteredSharedInformerFactory(client internalversion.Interface, defaultResync time.Duration, filter internalinterfaces.FilterFunc) SharedInformerFactory {
return &sharedInformerFactory{
client: client,
filter: filter,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
Expand Down Expand Up @@ -114,5 +121,5 @@ type SharedInformerFactory interface {
}

func (f *sharedInformerFactory) Navigator() navigator.Interface {
return navigator.New(f)
return navigator.New(f, f.filter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package internalinterfaces

import (
internalversion "github.com/jetstack/navigator/pkg/client/clientset/internalversion"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
time "time"
Expand All @@ -32,3 +33,15 @@ type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}

type FilterFunc func(*v1.ListOptions) (namespace string)

func DefaultFilterFunc(*v1.ListOptions) (namespace string) {
return v1.NamespaceAll
}

func NamespaceFilter(namespace string) FilterFunc {
return func(*v1.ListOptions) string {
return namespace
}
}
9 changes: 5 additions & 4 deletions pkg/client/informers/internalversion/navigator/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ type Interface interface {
}

type group struct {
internalinterfaces.SharedInformerFactory
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &group{f}
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
return &group{factory: f, filter: filter}
}

// InternalVersion returns a new internalversion.Interface.
func (g *group) InternalVersion() internalversion.Interface {
return internalversion.New(g.SharedInformerFactory)
return internalversion.New(g.factory, g.filter)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,29 @@ type ElasticsearchClusterInformer interface {

type elasticsearchClusterInformer struct {
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// NewElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewElasticsearchClusterInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
filter := internalinterfaces.NamespaceFilter(namespace)
return NewFilteredElasticsearchClusterInformer(client, filter, resyncPeriod, indexers)
}

// NewFilteredElasticsearchClusterInformer constructs a new informer for ElasticsearchCluster type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredElasticsearchClusterInformer(client clientset_internalversion.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
namespace := filter(&options)
return client.Navigator().ElasticsearchClusters(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
namespace := filter(&options)
return client.Navigator().ElasticsearchClusters(namespace).Watch(options)
},
},
Expand All @@ -60,12 +71,12 @@ func NewElasticsearchClusterInformer(client clientset_internalversion.Interface,
)
}

func defaultElasticsearchClusterInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewElasticsearchClusterInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
func (f *elasticsearchClusterInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredElasticsearchClusterInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
}

func (f *elasticsearchClusterInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&navigator.ElasticsearchCluster{}, defaultElasticsearchClusterInformer)
return f.factory.InformerFor(&navigator.ElasticsearchCluster{}, f.defaultInformer)
}

func (f *elasticsearchClusterInformer) Lister() internalversion.ElasticsearchClusterLister {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ type Interface interface {
}

type version struct {
internalinterfaces.SharedInformerFactory
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// New returns a new Interface.
func New(f internalinterfaces.SharedInformerFactory) Interface {
return &version{f}
func New(f internalinterfaces.SharedInformerFactory, filter internalinterfaces.FilterFunc) Interface {
return &version{factory: f, filter: filter}
}

// ElasticsearchClusters returns a ElasticsearchClusterInformer.
func (v *version) ElasticsearchClusters() ElasticsearchClusterInformer {
return &elasticsearchClusterInformer{factory: v.SharedInformerFactory}
return &elasticsearchClusterInformer{factory: v.factory, filter: v.filter}
}

// Pilots returns a PilotInformer.
func (v *version) Pilots() PilotInformer {
return &pilotInformer{factory: v.SharedInformerFactory}
return &pilotInformer{factory: v.factory, filter: v.filter}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,29 @@ type PilotInformer interface {

type pilotInformer struct {
factory internalinterfaces.SharedInformerFactory
filter internalinterfaces.FilterFunc
}

// NewPilotInformer constructs a new informer for Pilot type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewPilotInformer(client clientset_internalversion.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
filter := internalinterfaces.NamespaceFilter(namespace)
return NewFilteredPilotInformer(client, filter, resyncPeriod, indexers)
}

// NewFilteredPilotInformer constructs a new informer for Pilot type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredPilotInformer(client clientset_internalversion.Interface, filter internalinterfaces.FilterFunc, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
namespace := filter(&options)
return client.Navigator().Pilots(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
namespace := filter(&options)
return client.Navigator().Pilots(namespace).Watch(options)
},
},
Expand All @@ -60,12 +71,12 @@ func NewPilotInformer(client clientset_internalversion.Interface, namespace stri
)
}

func defaultPilotInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewPilotInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
func (f *pilotInformer) defaultInformer(client clientset_internalversion.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredPilotInformer(client, f.filter, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
}

func (f *pilotInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&navigator.Pilot{}, defaultPilotInformer)
return f.factory.InformerFor(&navigator.Pilot{}, f.defaultInformer)
}

func (f *pilotInformer) Lister() internalversion.PilotLister {
Expand Down
Loading

0 comments on commit fc82a71

Please sign in to comment.