Skip to content

Commit

Permalink
fix ruleset IndexField (#67)
Browse files Browse the repository at this point in the history
* fix ruleset IndexField

* fix ruleset ut
  • Loading branch information
Eikykun authored Aug 28, 2023
1 parent cc066e5 commit 54c8908
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 0 additions & 11 deletions pkg/controllers/ruleset/ruleset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import (
rulesetutils "kusionstack.io/kafed/pkg/controllers/ruleset/utils"
controllerutils "kusionstack.io/kafed/pkg/controllers/utils"
"kusionstack.io/kafed/pkg/utils"
"kusionstack.io/kafed/pkg/utils/inject"
)

const (
Expand Down Expand Up @@ -75,16 +74,6 @@ func addToMgr(mgr manager.Manager, r reconcile.Reconciler) (controller.Controlle
if err != nil {
return nil, err
}
err = mgr.GetCache().IndexField(context.TODO(), &appsv1alpha1.RuleSet{}, inject.FieldIndexRuleSet, func(obj client.Object) []string {
rs, ok := obj.(*appsv1alpha1.RuleSet)
if !ok {
return nil
}
return rs.Status.Targets
})
if err != nil {
return nil, err
}
// Watch for changes to RuleSet
err = c.Watch(&source.Kind{Type: &appsv1alpha1.RuleSet{}}, &RulesetEventHandler{})
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/controllers/ruleset/ruleset_controller_suit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

appsv1alpha1 "kusionstack.io/kafed/apis/apps/v1alpha1"
"kusionstack.io/kafed/pkg/utils/inject"
)

var (
Expand Down Expand Up @@ -70,6 +71,7 @@ func TestMain(m *testing.M) {
go func() {
mgr, err = manager.New(config, manager.Options{
MetricsBindAddress: "0",
NewCache: inject.NewCacheWithFieldIndex,
})
var r reconcile.Reconciler
r, request = testReconcile(newReconciler(mgr))
Expand Down

0 comments on commit 54c8908

Please sign in to comment.