From 4d424137707a23546b705ec866b51193dd048043 Mon Sep 17 00:00:00 2001 From: davidvader Date: Mon, 18 Sep 2023 16:52:17 -0500 Subject: [PATCH] chore: replace TODO with ctx --- cmd/vela-server/schedule.go | 12 ++++++------ database/build/list_deployment.go | 2 +- database/pipeline/list_repo.go | 2 +- database/pipeline/pipeline.go | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cmd/vela-server/schedule.go b/cmd/vela-server/schedule.go index 04aebb8df..0ca6024c4 100644 --- a/cmd/vela-server/schedule.go +++ b/cmd/vela-server/schedule.go @@ -173,7 +173,7 @@ func processSchedule(ctx context.Context, s *library.Schedule, compiler compiler } // send API call to capture the number of pending or running builds for the repo - builds, err := database.CountBuildsForRepo(context.TODO(), r, filters) + builds, err := database.CountBuildsForRepo(ctx, r, filters) if err != nil { return fmt.Errorf("unable to get count of builds for repo %s: %w", r.GetFullName(), err) } @@ -237,7 +237,7 @@ func processSchedule(ctx context.Context, s *library.Schedule, compiler compiler } // send API call to attempt to capture the pipeline - pipeline, err = database.GetPipelineForRepo(context.TODO(), b.GetCommit(), r) + pipeline, err = database.GetPipelineForRepo(ctx, b.GetCommit(), r) if err != nil { // assume the pipeline doesn't exist in the database yet // send API call to capture the pipeline configuration file config, err = scm.ConfigBackoff(ctx, u, r, b.GetCommit()) @@ -326,7 +326,7 @@ func processSchedule(ctx context.Context, s *library.Schedule, compiler compiler pipeline.SetRef(b.GetRef()) // send API call to create the pipeline - pipeline, err = database.CreatePipeline(context.TODO(), pipeline) + pipeline, err = database.CreatePipeline(ctx, pipeline) if err != nil { err = fmt.Errorf("failed to create pipeline for %s: %w", r.GetFullName(), err) @@ -351,7 +351,7 @@ func processSchedule(ctx context.Context, s *library.Schedule, compiler compiler // using the same Number and thus create a constraint // conflict; consider deleting the partially created // build object in the database - err = build.PlanBuild(context.TODO(), database, p, b, r) + err = build.PlanBuild(ctx, database, p, b, r) if err != nil { // check if the retry limit has been exceeded if i < retryLimit-1 { @@ -380,14 +380,14 @@ func processSchedule(ctx context.Context, s *library.Schedule, compiler compiler } // send API call to capture the triggered build - b, err = database.GetBuildForRepo(context.TODO(), r, b.GetNumber()) + b, err = database.GetBuildForRepo(ctx, r, b.GetNumber()) if err != nil { return fmt.Errorf("unable to get new build %s/%d: %w", r.GetFullName(), b.GetNumber(), err) } // publish the build to the queue go build.PublishToQueue( - context.TODO(), + ctx, queue, database, p, diff --git a/database/build/list_deployment.go b/database/build/list_deployment.go index 0d931fae7..e8f44f4b0 100644 --- a/database/build/list_deployment.go +++ b/database/build/list_deployment.go @@ -27,7 +27,7 @@ func (e *engine) ListBuildsForDeployment(ctx context.Context, d *library.Deploym builds := []*library.Build{} // count the results - count, err := e.CountBuildsForDeployment(context.TODO(), d, filters) + count, err := e.CountBuildsForDeployment(ctx, d, filters) if err != nil { return builds, 0, err } diff --git a/database/pipeline/list_repo.go b/database/pipeline/list_repo.go index e8c38afab..ce3983d23 100644 --- a/database/pipeline/list_repo.go +++ b/database/pipeline/list_repo.go @@ -28,7 +28,7 @@ func (e *engine) ListPipelinesForRepo(ctx context.Context, r *library.Repo, page pipelines := []*library.Pipeline{} // count the results - count, err := e.CountPipelinesForRepo(context.TODO(), r) + count, err := e.CountPipelinesForRepo(ctx, r) if err != nil { return pipelines, 0, err } diff --git a/database/pipeline/pipeline.go b/database/pipeline/pipeline.go index 7c9f29d8f..34852650f 100644 --- a/database/pipeline/pipeline.go +++ b/database/pipeline/pipeline.go @@ -53,7 +53,6 @@ func New(opts ...EngineOpt) (*engine, error) { e.client = new(gorm.DB) e.config = new(config) e.logger = new(logrus.Entry) - e.ctx = context.TODO() // apply all provided configuration options for _, opt := range opts {