Skip to content

Commit 9843ec3

Browse files
author
Gereon Frey
committed
Fix issue with NPE
`latest` is nil if the syncRoutes method is called from createRoutes.
1 parent 13385d6 commit 9843ec3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/resource/route_table/hooks.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ func (rm *resourceManager) syncRoutes(
6262

6363
// Get the routes that need to be added and deleted, by checking for
6464
// differences between desired and latest.
65-
toAdd, toDelete := getRoutesDifference(desired.ko.Spec.Routes, latest.ko.Spec.Routes)
65+
var toAdd, toDelete []*svcapitypes.CreateRouteInput
66+
if latest != nil {
67+
toAdd, toDelete = getRoutesDifference(desired.ko.Spec.Routes, latest.ko.Spec.Routes)
68+
} else {
69+
// If method is called from the createRoutes method, then latest is nil
70+
// and all routes must be added, as non exist yet.
71+
toAdd = desired.ko.Spec.Routes
72+
}
6673

6774
// Delete and add the routes that were found to be different between desired
6875
// and latest.

0 commit comments

Comments
 (0)