Skip to content

Commit

Permalink
Fix golangci-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
levikobi committed Jul 20, 2023
1 parent e67c8aa commit c376e66
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 90 deletions.
4 changes: 3 additions & 1 deletion controllers/tcproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ func (r *TCPRouteReconciler) SetupReconciliation(ctx context.Context) {
},
}

r.Reconcile(ctx, req)
if _, err := r.Reconcile(ctx, req); err != nil {
r.log.Error(err, "TCPRoute reconciliation failed")
}
}
}

Expand Down
44 changes: 0 additions & 44 deletions controllers/tcproute_controller_watch_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,13 @@ import (
"fmt"
"reflect"

"github.com/kong/blixt/pkg/vars"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
)

// mapDataPlaneDaemonsetToTCPRoutes is a mapping function to map dataplane
// DaemonSet updates to TCPRoute reconcilations. This enables changes to the
// DaemonSet such as adding new Pods for a new Node to result in new dataplane
// instances getting fully configured.
func (r *TCPRouteReconciler) mapDataPlaneDaemonsetToTCPRoutes(ctx context.Context, obj client.Object) (reqs []reconcile.Request) {
daemonset, ok := obj.(*appsv1.DaemonSet)
if !ok {
return
}

// determine if this is a blixt daemonset
matchLabels := daemonset.Spec.Selector.MatchLabels
app, ok := matchLabels["app"]
if !ok || app != vars.DefaultDataPlaneAppLabel {
return
}

// verify that it's the dataplane daemonset
component, ok := matchLabels["component"]
if !ok || component != vars.DefaultDataPlaneComponentLabel {
return
}

tcproutes := &gatewayv1alpha2.TCPRouteList{}
if err := r.Client.List(ctx, tcproutes); err != nil {
// TODO: https://github.com/kubernetes-sigs/controller-runtime/issues/1996
r.log.Error(err, "could not enqueue TCPRoutes for DaemonSet update")
return
}

for _, tcproute := range tcproutes.Items {
reqs = append(reqs, reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: tcproute.Namespace,
Name: tcproute.Name,
},
})
}

return
}

// mapGatewayToTCPRoutes enqueues reconcilation for all TCPRoutes whenever
// an event occurs on a relevant Gateway.
func (r *TCPRouteReconciler) mapGatewayToTCPRoutes(_ context.Context, obj client.Object) (reqs []reconcile.Request) {
Expand Down
4 changes: 3 additions & 1 deletion controllers/udproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ func (r *UDPRouteReconciler) SetupReconciliation(ctx context.Context) {
},
}

r.Reconcile(ctx, req)
if _, err := r.Reconcile(ctx, req); err != nil {
r.log.Error(err, "UDPRoute reconciliation failed")
}
}
}

Expand Down
44 changes: 0 additions & 44 deletions controllers/udproute_controller_watch_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,13 @@ import (
"fmt"
"reflect"

"github.com/kong/blixt/pkg/vars"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
)

// mapDataPlaneDaemonsetToUDPRoutes is a mapping function to map dataplane
// DaemonSet updates to UDPRoute reconcilations. This enables changes to the
// DaemonSet such as adding new Pods for a new Node to result in new dataplane
// instances getting fully configured.
func (r *UDPRouteReconciler) mapDataPlaneDaemonsetToUDPRoutes(ctx context.Context, obj client.Object) (reqs []reconcile.Request) {
daemonset, ok := obj.(*appsv1.DaemonSet)
if !ok {
return
}

// determine if this is a blixt daemonset
matchLabels := daemonset.Spec.Selector.MatchLabels
app, ok := matchLabels["app"]
if !ok || app != vars.DefaultDataPlaneAppLabel {
return
}

// verify that it's the dataplane daemonset
component, ok := matchLabels["component"]
if !ok || component != vars.DefaultDataPlaneComponentLabel {
return
}

udproutes := &gatewayv1alpha2.UDPRouteList{}
if err := r.Client.List(ctx, udproutes); err != nil {
// TODO: https://github.com/kubernetes-sigs/controller-runtime/issues/1996
r.log.Error(err, "could not enqueue UDPRoutes for DaemonSet update")
return
}

for _, udproute := range udproutes.Items {
reqs = append(reqs, reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: udproute.Namespace,
Name: udproute.Name,
},
})
}

return
}

// mapGatewayToUDPRoutes enqueues reconcilation for all UDPRoutes whenever
// an event occurs on a relevant Gateway.
func (r *UDPRouteReconciler) mapGatewayToUDPRoutes(_ context.Context, obj client.Object) (reqs []reconcile.Request) {
Expand Down

0 comments on commit c376e66

Please sign in to comment.