@@ -287,15 +287,18 @@ func (n ingressNetworkingV1Strategy) ConvertIngress() *Ingress {
287
287
if k8sPath .PathType != nil {
288
288
pathType = string (* k8sPath .PathType )
289
289
}
290
- paths [pathType + "-" + k8sPath .Path ] = & IngressPath {
290
+ pathKey := pathType + "-" + k8sPath .Path
291
+ paths [pathKey ] = & IngressPath {
291
292
Path : k8sPath .Path ,
292
293
PathTypeMatch : pathType ,
293
294
SvcNamespace : n .ig .GetNamespace (),
294
- SvcName : k8sPath .Backend .Service .Name ,
295
- SvcPortInt : int64 (k8sPath .Backend .Service .Port .Number ),
296
- SvcPortString : k8sPath .Backend .Service .Port .Name ,
297
295
Status : "" ,
298
296
}
297
+ if k8sPath .Backend .Service != nil {
298
+ paths [pathKey ].SvcName = k8sPath .Backend .Service .Name
299
+ paths [pathKey ].SvcPortInt = int64 (k8sPath .Backend .Service .Port .Number )
300
+ paths [pathKey ].SvcPortString = k8sPath .Backend .Service .Port .Name
301
+ }
299
302
}
300
303
if rule , ok := rules [k8sRule .Host ]; ok {
301
304
for path , ingressPath := range paths {
@@ -315,14 +318,17 @@ func (n ingressNetworkingV1Strategy) ConvertIngress() *Ingress {
315
318
if ingressBackend == nil {
316
319
return nil
317
320
}
318
- return & IngressPath {
321
+ ingPath := & IngressPath {
319
322
SvcNamespace : n .ig .GetNamespace (),
320
- SvcName : ingressBackend .Service .Name ,
321
- SvcPortInt : int64 (ingressBackend .Service .Port .Number ),
322
- SvcPortString : ingressBackend .Service .Port .Name ,
323
323
IsDefaultBackend : true ,
324
324
Status : "" ,
325
325
}
326
+ if ingressBackend .Service != nil {
327
+ ingPath .SvcName = ingressBackend .Service .Name
328
+ ingPath .SvcPortInt = int64 (ingressBackend .Service .Port .Number )
329
+ ingPath .SvcPortString = ingressBackend .Service .Port .Name
330
+ }
331
+ return ingPath
326
332
}(n .ig .Spec .DefaultBackend ),
327
333
TLS : func (ingressTLS []networkingv1.IngressTLS ) map [string ]* IngressTLS {
328
334
tls := make (map [string ]* IngressTLS )
0 commit comments