@@ -27,16 +27,7 @@ import (
27
27
triggerdeploymentconfigs "github.com/openshift/origin/pkg/image/trigger/deploymentconfigs"
28
28
)
29
29
30
- type ImageTriggerControllerConfig struct {
31
- HasBuilderEnabled bool
32
- HasDeploymentsEnabled bool
33
- HasDaemonSetsEnabled bool
34
- HasStatefulSetsEnabled bool
35
- HasCronJobsEnabled bool
36
- }
37
-
38
- func (c * ImageTriggerControllerConfig ) RunController (ctx ControllerContext ) (bool , error ) {
39
- //streamInformer := ctx.ImageInformers.Image().InternalVersion().ImageStreams().Informer()
30
+ func RunImageTriggerController (ctx ControllerContext ) (bool , error ) {
40
31
informer := ctx .ImageInformers .Image ().InternalVersion ().ImageStreams ()
41
32
42
33
buildClient , err := ctx .ClientBuilder .OpenshiftInternalBuildClient (bootstrappolicy .InfraImageTriggerControllerServiceAccountName )
@@ -63,51 +54,41 @@ func (c *ImageTriggerControllerConfig) RunController(ctx ControllerContext) (boo
63
54
Reactor : & triggerdeploymentconfigs.DeploymentConfigReactor {Client : appsClient .Apps ()},
64
55
},
65
56
}
66
- if ! c .HasBuilderEnabled {
67
- sources = append (sources , imagetriggercontroller.TriggerSource {
68
- Resource : schema.GroupResource {Group : "build.openshift.io" , Resource : "buildconfigs" },
69
- Informer : ctx .BuildInformers .Build ().InternalVersion ().BuildConfigs ().Informer (),
70
- Store : ctx .BuildInformers .Build ().InternalVersion ().BuildConfigs ().Informer ().GetIndexer (),
71
- TriggerFn : triggerbuildconfigs .NewBuildConfigTriggerIndexer ,
72
- Reactor : triggerbuildconfigs .NewBuildConfigReactor (bcInstantiator , kclient .Core ().RESTClient ()),
73
- })
74
- }
75
- if ! c .HasDeploymentsEnabled {
76
- sources = append (sources , imagetriggercontroller.TriggerSource {
77
- Resource : schema.GroupResource {Group : "extensions" , Resource : "deployments" },
78
- Informer : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().Deployments ().Informer (),
79
- Store : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().Deployments ().Informer ().GetIndexer (),
80
- TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
81
- Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
82
- })
83
- }
84
- if ! c .HasDaemonSetsEnabled {
85
- sources = append (sources , imagetriggercontroller.TriggerSource {
86
- Resource : schema.GroupResource {Group : "extensions" , Resource : "daemonsets" },
87
- Informer : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().DaemonSets ().Informer (),
88
- Store : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().DaemonSets ().Informer ().GetIndexer (),
89
- TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
90
- Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
91
- })
92
- }
93
- if ! c .HasStatefulSetsEnabled {
94
- sources = append (sources , imagetriggercontroller.TriggerSource {
95
- Resource : schema.GroupResource {Group : "apps" , Resource : "statefulsets" },
96
- Informer : ctx .ExternalKubeInformers .Apps ().V1beta1 ().StatefulSets ().Informer (),
97
- Store : ctx .ExternalKubeInformers .Apps ().V1beta1 ().StatefulSets ().Informer ().GetIndexer (),
98
- TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
99
- Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
100
- })
101
- }
102
- if ! c .HasCronJobsEnabled {
103
- sources = append (sources , imagetriggercontroller.TriggerSource {
104
- Resource : schema.GroupResource {Group : "batch" , Resource : "cronjobs" },
105
- Informer : ctx .ExternalKubeInformers .Batch ().V2alpha1 ().CronJobs ().Informer (),
106
- Store : ctx .ExternalKubeInformers .Batch ().V2alpha1 ().CronJobs ().Informer ().GetIndexer (),
107
- TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
108
- Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
109
- })
110
- }
57
+ sources = append (sources , imagetriggercontroller.TriggerSource {
58
+ Resource : schema.GroupResource {Group : "build.openshift.io" , Resource : "buildconfigs" },
59
+ Informer : ctx .BuildInformers .Build ().InternalVersion ().BuildConfigs ().Informer (),
60
+ Store : ctx .BuildInformers .Build ().InternalVersion ().BuildConfigs ().Informer ().GetIndexer (),
61
+ TriggerFn : triggerbuildconfigs .NewBuildConfigTriggerIndexer ,
62
+ Reactor : triggerbuildconfigs .NewBuildConfigReactor (bcInstantiator , kclient .Core ().RESTClient ()),
63
+ })
64
+ sources = append (sources , imagetriggercontroller.TriggerSource {
65
+ Resource : schema.GroupResource {Group : "extensions" , Resource : "deployments" },
66
+ Informer : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().Deployments ().Informer (),
67
+ Store : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().Deployments ().Informer ().GetIndexer (),
68
+ TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
69
+ Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
70
+ })
71
+ sources = append (sources , imagetriggercontroller.TriggerSource {
72
+ Resource : schema.GroupResource {Group : "extensions" , Resource : "daemonsets" },
73
+ Informer : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().DaemonSets ().Informer (),
74
+ Store : ctx .ExternalKubeInformers .Extensions ().V1beta1 ().DaemonSets ().Informer ().GetIndexer (),
75
+ TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
76
+ Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
77
+ })
78
+ sources = append (sources , imagetriggercontroller.TriggerSource {
79
+ Resource : schema.GroupResource {Group : "apps" , Resource : "statefulsets" },
80
+ Informer : ctx .ExternalKubeInformers .Apps ().V1beta1 ().StatefulSets ().Informer (),
81
+ Store : ctx .ExternalKubeInformers .Apps ().V1beta1 ().StatefulSets ().Informer ().GetIndexer (),
82
+ TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
83
+ Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
84
+ })
85
+ sources = append (sources , imagetriggercontroller.TriggerSource {
86
+ Resource : schema.GroupResource {Group : "batch" , Resource : "cronjobs" },
87
+ Informer : ctx .ExternalKubeInformers .Batch ().V2alpha1 ().CronJobs ().Informer (),
88
+ Store : ctx .ExternalKubeInformers .Batch ().V2alpha1 ().CronJobs ().Informer ().GetIndexer (),
89
+ TriggerFn : triggerannotations .NewAnnotationTriggerIndexer ,
90
+ Reactor : & triggerannotations.AnnotationReactor {Updater : updater },
91
+ })
111
92
112
93
go imagetriggercontroller .NewTriggerController (
113
94
broadcaster ,
0 commit comments