feat(runs,events,ui): identify workflows by immutable UUID (#2125)
This commit is contained in:
46 files changed
+1284
-512
No files matched your search
@@ -80,15 +80,16 @@ type TriggerSpec struct {
|
||||
SourceID uuid.UUID
|
||||
EventType string
|
||||
Filter map[string]string
|
||||
Workflow string
|
||||
// WorkflowID is the workflow the trigger starts.
|
||||
WorkflowID uuid.UUID
|
||||
}
|
||||
|
||||
// SaveTrigger creates or replaces an event trigger.
|
||||
func (m *Module) SaveTrigger(ctx context.Context, t TriggerSpec) error {
|
||||
if !validName.MatchString(t.Name) || t.SourceID == uuid.Nil || t.EventType == "" || t.Workflow == "" {
|
||||
if !validName.MatchString(t.Name) || t.SourceID == uuid.Nil || t.EventType == "" || t.WorkflowID == uuid.Nil {
|
||||
return fmt.Errorf("a trigger needs a lowercase name, a source, an event type and a workflow")
|
||||
}
|
||||
if err := m.runs.CheckTrigger(ctx, m.orgID, t.Workflow); err != nil {
|
||||
if err := m.runs.CheckTrigger(ctx, m.orgID, t.WorkflowID); err != nil {
|
||||
return err
|
||||
}
|
||||
filter, err := json.Marshal(t.Filter)
|
||||
@@ -97,6 +98,6 @@ func (m *Module) SaveTrigger(ctx context.Context, t TriggerSpec) error {
|
||||
}
|
||||
return m.store.UpsertTrigger(ctx, store.Trigger{
|
||||
OrgID: m.orgID, Name: t.Name, SourceID: uuid.NullUUID{UUID: t.SourceID, Valid: true}, EventType: t.EventType,
|
||||
Filter: filter, Workflow: t.Workflow, Enabled: true, Approved: true,
|
||||
Filter: filter, WorkflowID: t.WorkflowID, Enabled: true, Approved: true,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user