@@ -11,59 +11,101 @@ import (
11
11
"k8s.io/client-go/tools/cache"
12
12
kapi "k8s.io/kubernetes/pkg/api"
13
13
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake"
14
+ corelister "k8s.io/kubernetes/pkg/client/listers/core/v1"
14
15
15
16
deployapi "github.com/openshift/origin/pkg/apps/apis/apps"
16
17
_ "github.com/openshift/origin/pkg/apps/apis/apps/install"
17
18
testapi "github.com/openshift/origin/pkg/apps/apis/apps/test"
18
19
deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1"
19
20
appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake"
21
+ appslister "github.com/openshift/origin/pkg/apps/generated/listers/apps/internalversion"
20
22
imageapi "github.com/openshift/origin/pkg/image/apis/image"
21
23
imagefake "github.com/openshift/origin/pkg/image/generated/internalclientset/fake"
24
+ imagelister "github.com/openshift/origin/pkg/image/generated/listers/image/internalversion"
22
25
)
23
26
24
27
var (
25
28
codec = kapi .Codecs .LegacyCodec (deployv1 .SchemeGroupVersion )
26
- dcInformer = cache .NewSharedIndexInformer (
27
- & cache.ListWatch {
28
- ListFunc : func (options metav1.ListOptions ) (runtime.Object , error ) {
29
- return (appsfake .NewSimpleClientset ()).Apps ().DeploymentConfigs (metav1 .NamespaceAll ).List (options )
29
+ dcInformer = & fakeDeploymentConfigInformer {
30
+ informer : cache .NewSharedIndexInformer (
31
+ & cache.ListWatch {
32
+ ListFunc : func (options metav1.ListOptions ) (runtime.Object , error ) {
33
+ return (appsfake .NewSimpleClientset ()).Apps ().DeploymentConfigs (metav1 .NamespaceAll ).List (options )
34
+ },
35
+ WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
36
+ return (appsfake .NewSimpleClientset ()).Apps ().DeploymentConfigs (metav1 .NamespaceAll ).Watch (options )
37
+ },
30
38
},
31
- WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
32
- return (appsfake .NewSimpleClientset ()).Apps ().DeploymentConfigs (metav1 .NamespaceAll ).Watch (options )
33
- },
34
- },
35
- & deployapi.DeploymentConfig {},
36
- 2 * time .Minute ,
37
- cache.Indexers {cache .NamespaceIndex : cache .MetaNamespaceIndexFunc },
38
- )
39
- rcInformer = cache .NewSharedIndexInformer (
40
- & cache.ListWatch {
41
- ListFunc : func (options metav1.ListOptions ) (runtime.Object , error ) {
42
- return (fake .NewSimpleClientset ()).Core ().ReplicationControllers (metav1 .NamespaceAll ).List (options )
43
- },
44
- WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
45
- return (fake .NewSimpleClientset ()).Core ().ReplicationControllers (metav1 .NamespaceAll ).Watch (options )
46
- },
47
- },
48
- & kapi.ReplicationController {},
49
- 2 * time .Minute ,
50
- cache.Indexers {cache .NamespaceIndex : cache .MetaNamespaceIndexFunc },
51
- )
52
- streamInformer = cache .NewSharedIndexInformer (
53
- & cache.ListWatch {
54
- ListFunc : func (options metav1.ListOptions ) (runtime.Object , error ) {
55
- return (imagefake .NewSimpleClientset ()).Image ().ImageStreams (metav1 .NamespaceAll ).List (options )
39
+ & deployapi.DeploymentConfig {},
40
+ 2 * time .Minute ,
41
+ cache.Indexers {cache .NamespaceIndex : cache .MetaNamespaceIndexFunc },
42
+ ),
43
+ }
44
+ rcInformer = & fakeReplicationControllerInformer {
45
+ informer : cache .NewSharedIndexInformer (
46
+ & cache.ListWatch {
47
+ ListFunc : func (options metav1.ListOptions ) (runtime.Object , error ) {
48
+ return (fake .NewSimpleClientset ()).Core ().ReplicationControllers (metav1 .NamespaceAll ).List (options )
49
+ },
50
+ WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
51
+ return (fake .NewSimpleClientset ()).Core ().ReplicationControllers (metav1 .NamespaceAll ).Watch (options )
52
+ },
56
53
},
57
- WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
58
- return (imagefake .NewSimpleClientset ()).Image ().ImageStreams (metav1 .NamespaceAll ).Watch (options )
54
+ & kapi.ReplicationController {},
55
+ 2 * time .Minute ,
56
+ cache.Indexers {cache .NamespaceIndex : cache .MetaNamespaceIndexFunc },
57
+ ),
58
+ }
59
+ streamInformer = & fakeImageStreamInformer {
60
+ informer : cache .NewSharedIndexInformer (
61
+ & cache.ListWatch {
62
+ ListFunc : func (options metav1.ListOptions ) (runtime.Object , error ) {
63
+ return (imagefake .NewSimpleClientset ()).Image ().ImageStreams (metav1 .NamespaceAll ).List (options )
64
+ },
65
+ WatchFunc : func (options metav1.ListOptions ) (watch.Interface , error ) {
66
+ return (imagefake .NewSimpleClientset ()).Image ().ImageStreams (metav1 .NamespaceAll ).Watch (options )
67
+ },
59
68
},
60
- },
61
- & imageapi. ImageStream {} ,
62
- 2 * time . Minute ,
63
- cache. Indexers { cache . NamespaceIndex : cache . MetaNamespaceIndexFunc } ,
64
- )
69
+ & imageapi. ImageStream { },
70
+ 2 * time . Minute ,
71
+ cache. Indexers { cache . NamespaceIndex : cache . MetaNamespaceIndexFunc } ,
72
+ ) ,
73
+ }
65
74
)
66
75
76
+ type fakeDeploymentConfigInformer struct {
77
+ informer cache.SharedIndexInformer
78
+ }
79
+
80
+ func (f * fakeDeploymentConfigInformer ) Informer () cache.SharedIndexInformer {
81
+ return f .informer
82
+ }
83
+ func (f * fakeDeploymentConfigInformer ) Lister () appslister.DeploymentConfigLister {
84
+ return appslister .NewDeploymentConfigLister (f .informer .GetIndexer ())
85
+ }
86
+
87
+ type fakeReplicationControllerInformer struct {
88
+ informer cache.SharedIndexInformer
89
+ }
90
+
91
+ func (f * fakeReplicationControllerInformer ) Informer () cache.SharedIndexInformer {
92
+ return f .informer
93
+ }
94
+ func (f * fakeReplicationControllerInformer ) Lister () corelister.ReplicationControllerLister {
95
+ return corelister .NewReplicationControllerLister (f .informer .GetIndexer ())
96
+ }
97
+
98
+ type fakeImageStreamInformer struct {
99
+ informer cache.SharedIndexInformer
100
+ }
101
+
102
+ func (f * fakeImageStreamInformer ) Informer () cache.SharedIndexInformer {
103
+ return f .informer
104
+ }
105
+ func (f * fakeImageStreamInformer ) Lister () imagelister.ImageStreamLister {
106
+ return imagelister .NewImageStreamLister (f .informer .GetIndexer ())
107
+ }
108
+
67
109
// TestHandle_noTriggers ensures that a change to a config with no
68
110
// triggers doesn't result in a config instantiation.
69
111
func TestHandle_noTriggers (t * testing.T ) {
0 commit comments