This repository has been archived by the owner on Feb 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
/
stack.go
51 lines (43 loc) · 1.59 KB
/
stack.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package v1beta2
import (
"time"
"github.com/docker/compose-on-kubernetes/api/client/clientset"
"github.com/docker/compose-on-kubernetes/api/client/informers/internalinterfaces"
"github.com/docker/compose-on-kubernetes/api/client/listers/compose/v1beta2"
compose_v1beta2 "github.com/docker/compose-on-kubernetes/api/compose/v1beta2"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
// StackInformer provides access to a shared informer and lister for
// Stacks.
type StackInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1beta2.StackLister
}
type stackInformer struct {
factory internalinterfaces.SharedInformerFactory
}
func newStackInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.ComposeV1beta2().Stacks(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.ComposeV1beta2().Stacks(v1.NamespaceAll).Watch(options)
},
},
&compose_v1beta2.Stack{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
func (f *stackInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&compose_v1beta2.Stack{}, newStackInformer)
}
func (f *stackInformer) Lister() v1beta2.StackLister {
return v1beta2.NewStackLister(f.Informer().GetIndexer())
}