Skip to content

Commit

Permalink
fix: reconciler db
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Sep 18, 2024
1 parent 9ab32c3 commit 6aab029
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func run(cmd *cobra.Command, args []string) error {

if err = (&controllers.ScrapeConfigReconciler{
Client: mgr.GetClient(),
DB: dutyCtx.DB(),
Scheme: mgr.GetScheme(),
Log: ctrl.Log.WithName("controllers").WithName("scrape_config"),
}).SetupWithManager(mgr); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion controllers/scrapeconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

dutyContext "github.com/flanksource/duty/context"
"github.com/go-logr/logr"
"gorm.io/gorm"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -39,6 +40,7 @@ const ScrapeConfigFinalizerName = "scrapeConfig.config.flanksource.com"
// ScrapeConfigReconciler reconciles a ScrapeConfig object
type ScrapeConfigReconciler struct {
client.Client
DB *gorm.DB
Scheme *runtime.Scheme
Log logr.Logger
}
Expand Down Expand Up @@ -69,7 +71,7 @@ func (r *ScrapeConfigReconciler) Reconcile(c context.Context, req ctrl.Request)
return ctrl.Result{}, err
}

ctx := api.NewScrapeContext(dutyContext.NewContext(c)).WithScrapeConfig(scrapeConfig)
ctx := api.NewScrapeContext(dutyContext.NewContext(c).WithDB(r.DB, nil)).WithScrapeConfig(scrapeConfig)

// Check if it is deleted, remove scrape config
if !scrapeConfig.DeletionTimestamp.IsZero() {
Expand Down

0 comments on commit 6aab029

Please sign in to comment.