@@ -112,6 +112,49 @@ func (d *Deployment) listenForPVCEvents(stopCh <-chan struct{}) {
112
112
informer .Run (stopCh )
113
113
}
114
114
115
+ // listenForSecretEvents keep listening for changes in Secrets's until the given channel is closed.
116
+ func (d * Deployment ) listenForSecretEvents (stopCh <- chan struct {}) {
117
+ source := cache .NewListWatchFromClient (
118
+ d .deps .KubeCli .CoreV1 ().RESTClient (),
119
+ "secrets" ,
120
+ d .apiObject .GetNamespace (),
121
+ fields .Everything ())
122
+
123
+ getSecret := func (obj interface {}) (* v1.Secret , bool ) {
124
+ secret , ok := obj .(* v1.Secret )
125
+ if ! ok {
126
+ tombstone , ok := obj .(cache.DeletedFinalStateUnknown )
127
+ if ! ok {
128
+ return nil , false
129
+ }
130
+ secret , ok = tombstone .Obj .(* v1.Secret )
131
+ return secret , ok
132
+ }
133
+ return secret , true
134
+ }
135
+
136
+ _ , informer := cache .NewIndexerInformer (source , & v1.Secret {}, 0 , cache.ResourceEventHandlerFuncs {
137
+ // Note: For secrets we look at all of them because they do not have to be owned by this deployment.
138
+ AddFunc : func (obj interface {}) {
139
+ if _ , ok := getSecret (obj ); ok {
140
+ d .triggerInspection ()
141
+ }
142
+ },
143
+ UpdateFunc : func (oldObj , newObj interface {}) {
144
+ if _ , ok := getSecret (newObj ); ok {
145
+ d .triggerInspection ()
146
+ }
147
+ },
148
+ DeleteFunc : func (obj interface {}) {
149
+ if _ , ok := getSecret (obj ); ok {
150
+ d .triggerInspection ()
151
+ }
152
+ },
153
+ }, cache.Indexers {})
154
+
155
+ informer .Run (stopCh )
156
+ }
157
+
115
158
// listenForServiceEvents keep listening for changes in Service's until the given channel is closed.
116
159
func (d * Deployment ) listenForServiceEvents (stopCh <- chan struct {}) {
117
160
source := cache .NewListWatchFromClient (
0 commit comments