Skip to content

Commit

Permalink
indexer tests GatewayAPI before create
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Jun 3, 2024
1 parent 8a079e5 commit 8f6b2d5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/library/fieldindexers/httproute_parents.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ const (
// to prevent creating the same index field multiple times, the function is declared private to be
// called only by this controller
func HTTPRouteIndexByGateway(mgr ctrl.Manager, baseLogger logr.Logger) error {
ok, err := kuadrantgatewayapi.IsGatewayAPIInstalled(mgr.GetRESTMapper())
if err != nil {
return err

Check warning on line 27 in pkg/library/fieldindexers/httproute_parents.go

View check run for this annotation

Codecov / codecov/patch

pkg/library/fieldindexers/httproute_parents.go#L27

Added line #L27 was not covered by tests
}
if !ok {
baseLogger.Info("HTTPRouteIndexByGateway index disabled. GatewayAPI was not found")
return nil
}

if err := mgr.GetFieldIndexer().IndexField(context.Background(), &gatewayapiv1.HTTPRoute{}, HTTPRouteGatewayParentField, func(rawObj client.Object) []string {
// grab the route object, extract the parents
route, assertionOk := rawObj.(*gatewayapiv1.HTTPRoute)
Expand Down

0 comments on commit 8f6b2d5

Please sign in to comment.