Skip to content

Commit

Permalink
setup reconciler struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdiramen committed Feb 22, 2024
1 parent 547db3e commit 3d89bbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
7 changes: 5 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,11 @@ func runController(ctx context.Context, opts managerOpts) error {
}

if err = (&gatewaycontroller.HTTPRouteReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("Gateway"),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("gateway-controller"),
Driver: driver,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "HTTPRoute")
os.Exit(1)
Expand Down
22 changes: 8 additions & 14 deletions internal/controller/gateway/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ package gateway
import (
"context"

"github.com/go-logr/logr"
"github.com/ngrok/kubernetes-ingress-controller/internal/store"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -36,22 +39,13 @@ import (
// HTTPRouteReconciler reconciles a HTTPRoute object
type HTTPRouteReconciler struct {
client.Client
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=gateway.k8s.ngrok.com,resources=httproutes,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=gateway.k8s.ngrok.com,resources=httproutes/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=gateway.k8s.ngrok.com,resources=httproutes/finalizers,verbs=update
Log logr.Logger
Scheme *runtime.Scheme
Recorder record.EventRecorder
Driver *store.Driver
}

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
// TODO(user): Modify the Reconcile function to compare the state specified by
// the HTTPRoute object against the actual cluster state, and then
// perform operations to make the cluster state reflect the state specified by
// the user.
//
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile
func (r *HTTPRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = log.FromContext(ctx)

Expand Down

0 comments on commit 3d89bbc

Please sign in to comment.