Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to the triggered by btn #1701

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next/controllers/github_after_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func handlePushEventApplyAfterMerge(gh nextutils.GithubClientProvider, payload *
return fmt.Errorf("error creating digger run stage")
}

diggerRun, err := dbmodels.DB.CreateDiggerRun("push", 0, dbmodels.RunQueued, commitId, "", installationId, repo.ID, project.ID, projectName, dbmodels.PlanAndApply, planStage.ID, applyStage.ID)
diggerRun, err := dbmodels.DB.CreateDiggerRun("push", 0, dbmodels.RunQueued, commitId, "", installationId, repo.ID, project.ID, projectName, dbmodels.PlanAndApply, planStage.ID, applyStage.ID, nil)
if err != nil {
log.Printf("Error creating digger run: %v", err)
return fmt.Errorf("error creating digger run")
Expand Down
3 changes: 2 additions & 1 deletion next/controllers/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (d DiggerController) TriggerRunForProjectAssumingUser(c *gin.Context) {
return
}
projectId := request.ProjectId
userId := request.UserId

p := dbmodels.DB.Query.Project
project, err := dbmodels.DB.Query.Project.Where(p.ID.Eq(projectId)).First()
Expand Down Expand Up @@ -136,7 +137,7 @@ func (d DiggerController) TriggerRunForProjectAssumingUser(c *gin.Context) {
return
}

diggerRun, err := dbmodels.DB.CreateDiggerRun("push", 0, dbmodels.RunQueued, *commitSha, "", installationId, repoId, projectId, projectName, dbmodels.PlanAndApply, planStage.ID, applyStage.ID)
diggerRun, err := dbmodels.DB.CreateDiggerRun("user", 0, dbmodels.RunQueued, *commitSha, "", installationId, repoId, projectId, projectName, dbmodels.PlanAndApply, planStage.ID, applyStage.ID, &userId)
if err != nil {
log.Printf("Error creating digger run: %v", err)
c.JSON(http.StatusBadRequest, gin.H{"error": "error creating digger run"})
Expand Down
5 changes: 4 additions & 1 deletion next/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func main() {

// need to make approver_user_id nullable and gorm gen does not generate it as a string pointer, for some reason
g.ApplyBasic(
g.GenerateModel("digger_runs", gen.FieldType("approver_user_id", "*string")),
g.GenerateModel("digger_runs",
gen.FieldType("approver_user_id", "*string"),
gen.FieldType("triggered_by_user_id", "*string"),
),
)

g.ApplyBasic(
Expand Down
3 changes: 2 additions & 1 deletion next/dbmodels/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ func (db *Database) ListDiggerRunsForProject(projectName string, repoId uint) ([
return runs, nil
}

func (db *Database) CreateDiggerRun(Triggertype string, PrNumber int, Status DiggerRunStatus, CommitId string, DiggerConfig string, GithubInstallationId int64, RepoId int64, projectId string, ProjectName string, RunType RunType, planStageId string, applyStageId string) (*model.DiggerRun, error) {
func (db *Database) CreateDiggerRun(Triggertype string, PrNumber int, Status DiggerRunStatus, CommitId string, DiggerConfig string, GithubInstallationId int64, RepoId int64, projectId string, ProjectName string, RunType RunType, planStageId string, applyStageId string, triggeredByUserId *string) (*model.DiggerRun, error) {
dr := &model.DiggerRun{
ID: uuid.NewString(),
Triggertype: Triggertype,
Expand All @@ -774,6 +774,7 @@ func (db *Database) CreateDiggerRun(Triggertype string, PrNumber int, Status Dig
IsApproved: false,
ApprovalAuthor: "",
ApplyLogs: "",
TriggeredByUserID: triggeredByUserId,
}
result := db.GormDB.Create(dr)
if result.Error != nil {
Expand Down
1 change: 1 addition & 0 deletions next/model/digger_runs.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion next/models_generated/digger_runs.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading