Skip to content

Commit

Permalink
fix: set default context on serve mode (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored Oct 30, 2023
1 parent cec05dc commit 1602670
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
echopprof "github.com/sevennt/echo-pprof"
"go.opentelemetry.io/otel"

apicontext "github.com/flanksource/canary-checker/api/context"
"github.com/flanksource/canary-checker/pkg"
"github.com/flanksource/canary-checker/pkg/db"
"github.com/flanksource/canary-checker/pkg/jobs"
canaryJobs "github.com/flanksource/canary-checker/pkg/jobs/canary"
Expand All @@ -25,7 +28,9 @@ import (
"github.com/flanksource/canary-checker/pkg/api"
"github.com/flanksource/canary-checker/pkg/cache"
"github.com/flanksource/canary-checker/pkg/prometheus"
commonsCtx "github.com/flanksource/commons/context"
"github.com/flanksource/commons/logger"
dutyContext "github.com/flanksource/duty/context"
"github.com/flanksource/duty/models"
prom "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -61,6 +66,17 @@ func setup() {
logger.Fatalf("Error setting properties in database: %v", err)
}

kommonsClient, k8s, err := pkg.NewKommonsClient()
if err != nil {
logger.Warnf("failed to get kommons client, checks that read kubernetes configs will fail: %v", err)
}

apicontext.DefaultContext = dutyContext.NewContext(context.Background(), commonsCtx.WithTracer(otel.GetTracerProvider().Tracer("canary-checker"))).
WithDB(db.Gorm, db.Pool).
WithKubernetes(k8s).
WithKommons(kommonsClient).
WithNamespace(runner.WatchNamespace)

go push.Start()
}

Expand Down

0 comments on commit 1602670

Please sign in to comment.