Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/controller/consumer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/apache/apisix-ingress-controller/internal/provider"
internaltypes "github.com/apache/apisix-ingress-controller/internal/types"
"github.com/apache/apisix-ingress-controller/internal/utils"
pkgutils "github.com/apache/apisix-ingress-controller/pkg/utils"
)

// ConsumerReconciler reconciles a Gateway object.
Expand All @@ -60,6 +61,10 @@ type ConsumerReconciler struct { //nolint:revive

// SetupWithManager sets up the controller with the Manager.
func (r *ConsumerReconciler) SetupWithManager(mgr ctrl.Manager) error {
if config.ControllerConfig.DisableGatewayAPI || !pkgutils.HasAPIResource(mgr, &gatewayv1.Gateway{}) {
r.Log.Info("skipping Consumer controller setup as Gateway API is not available")
return nil
}
return ctrl.NewControllerManagedBy(mgr).
For(&v1alpha1.Consumer{},
builder.WithPredicates(
Expand Down
31 changes: 19 additions & 12 deletions internal/controller/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/apache/apisix-ingress-controller/internal/provider"
internaltypes "github.com/apache/apisix-ingress-controller/internal/types"
"github.com/apache/apisix-ingress-controller/internal/utils"
pkgutils "github.com/apache/apisix-ingress-controller/pkg/utils"
)

// GatewayReconciler reconciles a Gateway object.
Expand Down Expand Up @@ -83,18 +84,6 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error {
&gatewayv1.GRPCRoute{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForStatusParentRefs),
).
Watches(
&gatewayv1alpha2.TCPRoute{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForStatusParentRefs),
).
Watches(
&gatewayv1alpha2.TLSRoute{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForStatusParentRefs),
).
Watches(
&gatewayv1alpha2.UDPRoute{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForStatusParentRefs),
).
Watches(
&v1alpha1.GatewayProxy{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForGatewayProxy),
Expand All @@ -110,6 +99,24 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error {
builder.WithPredicates(referenceGrantPredicates(KindGateway)),
)
}
if pkgutils.HasAPIResource(mgr, &gatewayv1alpha2.TCPRoute{}) {
bdr.Watches(
&gatewayv1alpha2.TCPRoute{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForStatusParentRefs),
)
}
if pkgutils.HasAPIResource(mgr, &gatewayv1alpha2.TLSRoute{}) {
bdr.Watches(
&gatewayv1alpha2.TLSRoute{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForStatusParentRefs),
)
}
if pkgutils.HasAPIResource(mgr, &gatewayv1alpha2.UDPRoute{}) {
bdr.Watches(
&gatewayv1alpha2.UDPRoute{},
handler.EnqueueRequestsFromMapFunc(r.listGatewaysForStatusParentRefs),
)
}

return bdr.Complete(r)
}
Expand Down
Loading