From ac2fcb2ca7594d077a57812e7acc367cec3169e6 Mon Sep 17 00:00:00 2001 From: Mohamed Habib Date: Fri, 22 Nov 2024 16:24:25 +0000 Subject: [PATCH] use workflow from project setting (#1841) --- next/dbmodels/projects.go | 14 +++++++------- next/model/projects.gen.go | 1 + next/models_generated/projects.gen.go | 6 +++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/next/dbmodels/projects.go b/next/dbmodels/projects.go index 8fe105543..4e320e814 100644 --- a/next/dbmodels/projects.go +++ b/next/dbmodels/projects.go @@ -9,18 +9,18 @@ import ( func ToDiggerProject(p *model.Project) digger_config.Project { return digger_config.Project{ - Name: p.Name, - Dir: p.TerraformWorkingDir, - Workspace: func() string { + Name: p.Name, + Dir: p.TerraformWorkingDir, + Workspace: func() string { if p.Workspace == "" { return "default" } return p.Workspace }(), - Terragrunt: (p.IacType == "terragrunt"), - OpenTofu: (p.IacType == "opentofu"), - Workflow: "default", - WorkflowFile: func() string { + Terragrunt: (p.IacType == "terragrunt"), + OpenTofu: (p.IacType == "opentofu"), + Workflow: p.Workflow, + WorkflowFile: func() string { if p.WorkflowFile == "" { return "digger_workflow.yml" } diff --git a/next/model/projects.gen.go b/next/model/projects.gen.go index 58e4d74b2..1b43a23ac 100644 --- a/next/model/projects.gen.go +++ b/next/model/projects.gen.go @@ -42,6 +42,7 @@ type Project struct { IncludePatterns string `gorm:"column:include_patterns" json:"include_patterns"` AutoApprove bool `gorm:"column:auto_approve;not null" json:"auto_approve"` ExcludePatterns string `gorm:"column:exclude_patterns" json:"exclude_patterns"` + Workflow string `gorm:"column:workflow;default:default" json:"workflow"` } // TableName Project's table name diff --git a/next/models_generated/projects.gen.go b/next/models_generated/projects.gen.go index 94591da15..1e4791747 100644 --- a/next/models_generated/projects.gen.go +++ b/next/models_generated/projects.gen.go @@ -55,6 +55,7 @@ func newProject(db *gorm.DB, opts ...gen.DOOption) project { _project.IncludePatterns = field.NewString(tableName, "include_patterns") _project.AutoApprove = field.NewBool(tableName, "auto_approve") _project.ExcludePatterns = field.NewString(tableName, "exclude_patterns") + _project.Workflow = field.NewString(tableName, "workflow") _project.fillFieldMap() @@ -93,6 +94,7 @@ type project struct { IncludePatterns field.String AutoApprove field.Bool ExcludePatterns field.String + Workflow field.String fieldMap map[string]field.Expr } @@ -137,6 +139,7 @@ func (p *project) updateTableName(table string) *project { p.IncludePatterns = field.NewString(table, "include_patterns") p.AutoApprove = field.NewBool(table, "auto_approve") p.ExcludePatterns = field.NewString(table, "exclude_patterns") + p.Workflow = field.NewString(table, "workflow") p.fillFieldMap() @@ -153,7 +156,7 @@ func (p *project) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (p *project) fillFieldMap() { - p.fieldMap = make(map[string]field.Expr, 28) + p.fieldMap = make(map[string]field.Expr, 29) p.fieldMap["id"] = p.ID p.fieldMap["name"] = p.Name p.fieldMap["created_at"] = p.CreatedAt @@ -182,6 +185,7 @@ func (p *project) fillFieldMap() { p.fieldMap["include_patterns"] = p.IncludePatterns p.fieldMap["auto_approve"] = p.AutoApprove p.fieldMap["exclude_patterns"] = p.ExcludePatterns + p.fieldMap["workflow"] = p.Workflow } func (p project) clone(db *gorm.DB) project {