This repository has been archived by the owner on Dec 18, 2019. It is now read-only.
/
watches.go
61 lines (55 loc) · 2.37 KB
/
watches.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
52
53
54
55
56
57
58
59
60
61
package mobilesecurityservice
import (
mobilesecurityservicev1alpha1 "github.com/aerogear/mobile-security-service-operator/pkg/apis/mobilesecurityservice/v1alpha1"
routev1 "github.com/openshift/api/route/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/source"
)
//Watch for changes to secondary resources and create the owner MobileSecurityService
//Watch ConfigMap resources created in the project/namespace
func watchConfigMap(c controller.Controller) error {
err := c.Watch(&source.Kind{Type: &corev1.ConfigMap{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &mobilesecurityservicev1alpha1.MobileSecurityService{},
})
return err
}
//Watch for changes to secondary resources and create the owner MobileSecurityService
//Watch Service resources created in the project/namespace
func watchService(c controller.Controller) error {
err := c.Watch(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &mobilesecurityservicev1alpha1.MobileSecurityService{},
})
return err
}
//Watch for changes to secondary resources and create the owner MobileSecurityService
//Watch Deployment resources created in the project/namespace
func watchDeployment(c controller.Controller) error {
err := c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &mobilesecurityservicev1alpha1.MobileSecurityService{},
})
return err
}
//Watch for changes to secondary resources and requeue the owner MobileSecurityService
//Watch Route resources created in the project/namespace
func watchRoute(c controller.Controller) error {
err := c.Watch(&source.Kind{Type: &routev1.Route{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &mobilesecurityservicev1alpha1.MobileSecurityService{},
})
return err
}
//Watch for changes to secondary resources and requeue the owner MobileSecurityService
//Watch ServiceAccount resources created in the project/namespace
func watchServiceAccount(c controller.Controller) error {
err := c.Watch(&source.Kind{Type: &corev1.ServiceAccount{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &mobilesecurityservicev1alpha1.MobileSecurityService{},
})
return err
}