Skip to content

Commit

Permalink
chore: replace TODO with ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Sep 18, 2023
1 parent b695599 commit 4d42413
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions cmd/vela-server/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)

Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion database/build/list_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion database/pipeline/list_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion database/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4d42413

Please sign in to comment.