feat(sources): add sources and workflows to the backend BE-12919 (#2666)

This commit is contained in:
andres-portainer
2026-05-20 20:42:10 -03:00
committed by GitHub
parent 4cd8c04691
commit 3d09c70e13
71 changed files with 3117 additions and 317 deletions

View File

@@ -66,7 +66,36 @@ func (b *GitMethodStackBuilder) prepare(ctx context.Context, payload *StackPaylo
// Update the latest commit id
repoConfig.ConfigHash = commitHash
b.stack.GitConfig = &repoConfig
var workflowID portainer.WorkflowID
if err := b.dataStore.UpdateTx(func(tx dataservices.DataStoreTx) error {
repoConfig.URL = gittypes.SanitizeURL(repoConfig.URL)
src, err := dataservices.FindOrCreateGitSource(tx, &portainer.Source{
Name: gittypes.RepoName(repoConfig.URL),
Type: portainer.SourceTypeGit,
GitConfig: &repoConfig,
})
if err != nil {
return fmt.Errorf("failed to find or create source: %w", err)
}
wf := &portainer.Workflow{
SourceIDs: []portainer.SourceID{src.ID},
}
if err := tx.Workflow().Create(wf); err != nil {
return fmt.Errorf("failed to create workflow: %w", err)
}
workflowID = wf.ID
return nil
}); err != nil {
return err
}
b.stack.WorkflowID = workflowID
return nil
}