Skip to content

Commit

Permalink
Merge pull request #356 from MUzairS15/uzair
Browse files Browse the repository at this point in the history
Add support to configure broker service
  • Loading branch information
leecalcote committed Sep 19, 2022
2 parents cc49b1d + 8af467d commit 6ce33e1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions controllers/meshsync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ import (
"context"

"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

mesheryv1alpha1 "github.com/layer5io/meshery-operator/api/v1alpha1"
brokerpackage "github.com/layer5io/meshery-operator/pkg/broker"
Expand Down Expand Up @@ -93,6 +98,8 @@ func (r *MeshSyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
func (r *MeshSyncReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&mesheryv1alpha1.MeshSync{}).
Watches(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForObject{}).
WithEventFilter(updatePredicate()).
Complete(r)
}

Expand Down Expand Up @@ -158,3 +165,15 @@ func (r *MeshSyncReconciler) reconcileMeshsync(ctx context.Context, enable bool,

return ctrl.Result{}, nil
}

func updatePredicate() predicate.Predicate {
return predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
val, ok := e.ObjectNew.GetLabels()["component"]
if ok && val == "broker" {
return ok
}
return !ok
},
}
}

0 comments on commit 6ce33e1

Please sign in to comment.