@@ -262,18 +262,21 @@ func (n ingressNetworkingV1Strategy) ConvertIngress() *Ingress {
262
262
continue
263
263
}
264
264
for _ , k8sPath := range k8sRule .HTTP .Paths {
265
- prefix := ""
265
+ var pathType string
266
266
if k8sPath .PathType != nil {
267
- prefix = string (* k8sPath .PathType )
267
+ pathType = string (* k8sPath .PathType )
268
268
}
269
- paths [prefix + "-" + k8sPath .Path ] = & IngressPath {
269
+ pathKey := pathType + "-" + k8sPath .Path
270
+ paths [pathKey ] = & IngressPath {
270
271
Path : k8sPath .Path ,
271
272
ExactPathMatch : k8sPath .PathType != nil && * k8sPath .PathType == networkingv1 .PathTypeExact ,
272
- SvcName : k8sPath .Backend .Service .Name ,
273
- SvcPortInt : int64 (k8sPath .Backend .Service .Port .Number ),
274
- SvcPortString : k8sPath .Backend .Service .Port .Name ,
275
273
Status : "" ,
276
274
}
275
+ if k8sPath .Backend .Service != nil {
276
+ paths [pathKey ].SvcName = k8sPath .Backend .Service .Name
277
+ paths [pathKey ].SvcPortInt = int64 (k8sPath .Backend .Service .Port .Number )
278
+ paths [pathKey ].SvcPortString = k8sPath .Backend .Service .Port .Name
279
+ }
277
280
}
278
281
if rule , ok := rules [k8sRule .Host ]; ok {
279
282
for path , ingressPath := range paths {
@@ -293,13 +296,16 @@ func (n ingressNetworkingV1Strategy) ConvertIngress() *Ingress {
293
296
if ingressBackend == nil {
294
297
return nil
295
298
}
296
- return & IngressPath {
297
- SvcName : ingressBackend .Service .Name ,
298
- SvcPortInt : int64 (ingressBackend .Service .Port .Number ),
299
- SvcPortString : ingressBackend .Service .Port .Name ,
299
+ ingPath := & IngressPath {
300
300
IsDefaultBackend : true ,
301
301
Status : "" ,
302
302
}
303
+ if ingressBackend .Service != nil {
304
+ ingPath .SvcName = ingressBackend .Service .Name
305
+ ingPath .SvcPortInt = int64 (ingressBackend .Service .Port .Number )
306
+ ingPath .SvcPortString = ingressBackend .Service .Port .Name
307
+ }
308
+ return ingPath
303
309
}(n .ig .Spec .DefaultBackend ),
304
310
TLS : func (ingressTLS []networkingv1.IngressTLS ) map [string ]* IngressTLS {
305
311
tls := make (map [string ]* IngressTLS )
0 commit comments