@@ -35,11 +35,11 @@ import (
3535 "k8s.io/client-go/tools/cache"
3636)
3737
38- type ingressValue struct {
39- name string
40- host string
41- path string
42- targets []string
38+ type IngressValue struct {
39+ Name string
40+ Host string
41+ Path string
42+ Targets []string
4343}
4444
4545// IngressWatcher watches for changes in Kubernetes Ingress resources and updates the ingress cache accordingly
@@ -133,22 +133,22 @@ func (iw *IngressWatcher) AddHandler(obj interface{}) {
133133 return
134134 }
135135
136- if err := iw .cache .Set (ingress .host , ingress .path , ingress .targets ); err != nil {
136+ if err := iw .cache .Set (ingress .Host , ingress .Path , ingress .Targets ); err != nil {
137137 iw .logger .WarnWith ("Add ingress handler failure - failed to add the new value to ingress cache" ,
138138 "error" , err .Error (),
139139 "object" , obj ,
140- "ingressName" , ingress .name ,
141- "host" , ingress .host ,
142- "path" , ingress .path ,
143- "targets" , ingress .targets )
140+ "ingressName" , ingress .Name ,
141+ "host" , ingress .Host ,
142+ "path" , ingress .Path ,
143+ "targets" , ingress .Targets )
144144 return
145145 }
146146
147147 iw .logger .DebugWith ("Add ingress handler - successfully added ingress to cache" ,
148- "ingressName" , ingress .name ,
149- "host" , ingress .host ,
150- "path" , ingress .path ,
151- "targets" , ingress .targets )
148+ "ingressName" , ingress .Name ,
149+ "host" , ingress .Host ,
150+ "path" , ingress .Path ,
151+ "targets" , ingress .Targets )
152152}
153153
154154func (iw * IngressWatcher ) UpdateHandler (oldObj , newObj interface {}) {
@@ -187,34 +187,34 @@ func (iw *IngressWatcher) UpdateHandler(oldObj, newObj interface{}) {
187187 }
188188
189189 // if the host or path has changed, we need to delete the old entry
190- if oldIngress .host != newIngress .host || oldIngress .path != newIngress .path {
191- if err := iw .cache .Delete (oldIngress .host , oldIngress .path , oldIngress .targets ); err != nil {
190+ if oldIngress .Host != newIngress .Host || oldIngress .Path != newIngress .Path {
191+ if err := iw .cache .Delete (oldIngress .Host , oldIngress .Path , oldIngress .Targets ); err != nil {
192192 iw .logger .WarnWith ("Update ingress handler failure - failed to delete old ingress" ,
193193 "error" , err .Error (),
194- "ingressName" , oldIngress .name ,
194+ "ingressName" , oldIngress .Name ,
195195 "object" , oldObj ,
196- "host" , oldIngress .host ,
197- "path" , oldIngress .path ,
198- "targets" , oldIngress .targets )
196+ "host" , oldIngress .Host ,
197+ "path" , oldIngress .Path ,
198+ "targets" , oldIngress .Targets )
199199 }
200200 }
201201
202- if err := iw .cache .Set (newIngress .host , newIngress .path , newIngress .targets ); err != nil {
202+ if err := iw .cache .Set (newIngress .Host , newIngress .Path , newIngress .Targets ); err != nil {
203203 iw .logger .WarnWith ("Update ingress handler failure - failed to add the new value" ,
204204 "error" , err .Error (),
205205 "object" , newObj ,
206- "ingressName" , newIngress .name ,
207- "host" , newIngress .host ,
208- "path" , newIngress .path ,
209- "targets" , newIngress .targets )
206+ "ingressName" , newIngress .Name ,
207+ "host" , newIngress .Host ,
208+ "path" , newIngress .Path ,
209+ "targets" , newIngress .Targets )
210210 return
211211 }
212212
213213 iw .logger .DebugWith ("Update ingress handler - successfully updated ingress in cache" ,
214- "ingressName" , newIngress .name ,
215- "host" , newIngress .host ,
216- "path" , newIngress .path ,
217- "targets" , newIngress .targets )
214+ "ingressName" , newIngress .Name ,
215+ "host" , newIngress .Host ,
216+ "path" , newIngress .Path ,
217+ "targets" , newIngress .Targets )
218218}
219219
220220func (iw * IngressWatcher ) DeleteHandler (obj interface {}) {
@@ -225,28 +225,28 @@ func (iw *IngressWatcher) DeleteHandler(obj interface{}) {
225225 return
226226 }
227227
228- if err := iw .cache .Delete (ingress .host , ingress .path , ingress .targets ); err != nil {
228+ if err := iw .cache .Delete (ingress .Host , ingress .Path , ingress .Targets ); err != nil {
229229 iw .logger .WarnWith ("Delete ingress handler failure - failed delete from cache" ,
230230 "error" , err .Error (),
231231 "object" , obj ,
232- "ingressName" , ingress .name ,
233- "host" , ingress .host ,
234- "path" , ingress .path ,
235- "targets" , ingress .targets )
232+ "ingressName" , ingress .Name ,
233+ "host" , ingress .Host ,
234+ "path" , ingress .Path ,
235+ "targets" , ingress .Targets )
236236 return
237237 }
238238
239239 iw .logger .DebugWith ("Delete ingress handler - successfully deleted ingress from cache" ,
240- "ingressName" , ingress .name ,
241- "host" , ingress .host ,
242- "path" , ingress .path ,
243- "targets" , ingress .targets )
240+ "ingressName" , ingress .Name ,
241+ "host" , ingress .Host ,
242+ "path" , ingress .Path ,
243+ "targets" , ingress .Targets )
244244}
245245
246246// --- internal methods ---
247247
248248// extractValuesFromIngressResource extracts the relevant values from a Kubernetes Ingress resource
249- func (iw * IngressWatcher ) extractValuesFromIngressResource (obj interface {}) (* ingressValue , error ) {
249+ func (iw * IngressWatcher ) extractValuesFromIngressResource (obj interface {}) (* IngressValue , error ) {
250250 ingress , ok := obj .(* networkingv1.Ingress )
251251 if ! ok {
252252 return nil , errors .New ("Failed to cast object to Ingress" )
@@ -271,11 +271,11 @@ func (iw *IngressWatcher) extractValuesFromIngressResource(obj interface{}) (*in
271271 return nil , errors .Wrap (err , "Failed to extract path from ingress" )
272272 }
273273
274- return & ingressValue {
275- host : host ,
276- path : path ,
277- targets : targets ,
278- name : ingress .Name ,
274+ return & IngressValue {
275+ Host : host ,
276+ Path : path ,
277+ Targets : targets ,
278+ Name : ingress .Name ,
279279 }, nil
280280}
281281
0 commit comments