Skip to content

Commit 3739bcd

Browse files
authored
feat(db): Expose workflow template ID (#3159)
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
1 parent f43ea19 commit 3739bcd

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

app/controlplane/pkg/biz/workflow.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ type Workflow struct {
4747
// This field is also used to calculate if an user can download attestations/materials from the CAS
4848
Public bool
4949
ProjectID uuid.UUID
50+
// WorkflowTemplateID references the platform workflow template this workflow was created from
51+
WorkflowTemplateID *uuid.UUID
5052
}
5153

5254
// WorkflowRef is a reference to a workflow
@@ -88,6 +90,8 @@ type WorkflowCreateOpts struct {
8890
UserIsOrgAdmin bool
8991
// OrgRestrictContractCreationToAdmins is the organization's setting for restricting contract creation
9092
OrgRestrictContractCreationToAdmins bool
93+
// WorkflowTemplateID optionally references the platform workflow template this workflow is created from
94+
WorkflowTemplateID *uuid.UUID
9195
}
9296

9397
type WorkflowUpdateOpts struct {

app/controlplane/pkg/data/workflow.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ func (r *WorkflowRepo) Create(ctx context.Context, opts *biz.WorkflowCreateOpts)
209209
SetContractID(contractUUID).
210210
SetOrganizationID(orgUUID).
211211
SetDescription(opts.Description).
212+
SetNillableWorkflowTemplateID(opts.WorkflowTemplateID).
212213
Save(ctx)
213214
if err != nil {
214215
if ent.IsConstraintError(err) {
@@ -492,12 +493,13 @@ func (r *WorkflowRepo) SoftDelete(ctx context.Context, id uuid.UUID) (err error)
492493

493494
func entWFToBizWF(ctx context.Context, w *ent.Workflow) (*biz.Workflow, error) {
494495
wf := &biz.Workflow{Name: w.Name, ID: w.ID,
495-
CreatedAt: toTimePtr(w.CreatedAt), Team: w.Team,
496-
RunsCounter: w.RunsCount,
497-
Public: w.Public,
498-
Description: w.Description,
499-
OrgID: w.OrganizationID,
500-
ProjectID: w.ProjectID,
496+
CreatedAt: toTimePtr(w.CreatedAt), Team: w.Team,
497+
RunsCounter: w.RunsCount,
498+
Public: w.Public,
499+
Description: w.Description,
500+
OrgID: w.OrganizationID,
501+
ProjectID: w.ProjectID,
502+
WorkflowTemplateID: w.WorkflowTemplateID,
501503
}
502504

503505
// Set p either pre-loaded or queried

0 commit comments

Comments
 (0)