Skip to content

Commit

Permalink
enhanced gateway api topology (#751)
Browse files Browse the repository at this point in the history
* enhanced gateway api topology

* address lint issues

* address reviewdog issues

* rlp enforced status catches all kind of gateways

* topology api consistency
  • Loading branch information
eguzki authored Jul 22, 2024
1 parent c8d02d0 commit 7745a19
Show file tree
Hide file tree
Showing 13 changed files with 431 additions and 82 deletions.
2 changes: 2 additions & 0 deletions controllers/authpolicy_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func (r *AuthPolicyReconciler) generateTopology(ctx context.Context) (*kuadrantg
})

return kuadrantgatewayapi.NewTopology(
kuadrantgatewayapi.WithAcceptedRoutesLinkedOnly(),
kuadrantgatewayapi.WithProgrammedGatewaysOnly(),
kuadrantgatewayapi.WithGateways(utils.Map(gwList.Items, ptr.To[gatewayapiv1.Gateway])),
kuadrantgatewayapi.WithRoutes(utils.Map(routeList.Items, ptr.To[gatewayapiv1.HTTPRoute])),
kuadrantgatewayapi.WithPolicies(policies),
Expand Down
1 change: 1 addition & 0 deletions controllers/ratelimitpolicy_enforced_status_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func (r *RateLimitPolicyEnforcedStatusReconciler) buildTopology(ctx context.Cont
}

return kuadrantgatewayapi.NewTopology(
kuadrantgatewayapi.WithAcceptedRoutesLinkedOnly(),
kuadrantgatewayapi.WithGateways(utils.Map(gatewayList.Items, ptr.To[gatewayapiv1.Gateway])),
kuadrantgatewayapi.WithRoutes(utils.Map(routeList.Items, ptr.To[gatewayapiv1.HTTPRoute])),
kuadrantgatewayapi.WithPolicies(utils.Map(policyList.Items, func(p kuadrantv1beta2.RateLimitPolicy) kuadrantgatewayapi.Policy { return &p })),
Expand Down
2 changes: 2 additions & 0 deletions controllers/ratelimitpolicy_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ func (r *RateLimitPolicyReconciler) buildTopology(ctx context.Context, policies
}

return kuadrantgatewayapi.NewTopology(
kuadrantgatewayapi.WithAcceptedRoutesLinkedOnly(),
kuadrantgatewayapi.WithProgrammedGatewaysOnly(),
kuadrantgatewayapi.WithGateways(utils.Map(gwList.Items, ptr.To[gatewayapiv1.Gateway])),
kuadrantgatewayapi.WithRoutes(utils.Map(routeList.Items, ptr.To[gatewayapiv1.HTTPRoute])),
kuadrantgatewayapi.WithPolicies(policies),
Expand Down
2 changes: 2 additions & 0 deletions controllers/target_status_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ func (r *TargetStatusReconciler) buildTopology(ctx context.Context, gw *gatewaya
}

t, err := kuadrantgatewayapi.NewTopology(
kuadrantgatewayapi.WithAcceptedRoutesLinkedOnly(),
kuadrantgatewayapi.WithProgrammedGatewaysOnly(),
kuadrantgatewayapi.WithGateways([]*gatewayapiv1.Gateway{gw}),
kuadrantgatewayapi.WithRoutes(utils.Map(routeList.Items, ptr.To[gatewayapiv1.HTTPRoute])),
kuadrantgatewayapi.WithPolicies(policies),
Expand Down
19 changes: 19 additions & 0 deletions pkg/library/gatewayapi/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,22 @@ func testBasicRoutePolicy(name, namespace string, route *gatewayapiv1.HTTPRoute)
},
}
}

func testStandalonePolicy(name, namespace string) Policy {
return &TestPolicy{
TypeMeta: metav1.TypeMeta{
APIVersion: "example.com/v1",
Kind: "TestPolicy",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: name,
},
TargetRef: gatewayapiv1alpha2.PolicyTargetReference{
Group: gatewayapiv1.Group(gatewayapiv1.GroupName),
Kind: gatewayapiv1.Kind("Gateway"),
Namespace: ptr.To(gatewayapiv1.Namespace("unknown")),
Name: gatewayapiv1.ObjectName("unknown"),
},
}
}
Loading

0 comments on commit 7745a19

Please sign in to comment.