feat(workflows): introduce Artifacts BE-12919 (#2740)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/portainer/portainer/api/dataservices"
|
||||
"github.com/portainer/portainer/api/filesystem"
|
||||
gittypes "github.com/portainer/portainer/api/git/types"
|
||||
"github.com/portainer/portainer/api/gitops/workflows"
|
||||
"github.com/portainer/portainer/api/scheduler"
|
||||
"github.com/portainer/portainer/api/stacks/deployments"
|
||||
"github.com/portainer/portainer/api/stacks/stackutils"
|
||||
@@ -72,7 +73,7 @@ func (b *GitMethodStackBuilder) prepare(ctx context.Context, payload *StackPaylo
|
||||
if err := b.dataStore.UpdateTx(func(tx dataservices.DataStoreTx) error {
|
||||
repoConfig.URL = gittypes.SanitizeURL(repoConfig.URL)
|
||||
|
||||
src, err := dataservices.FindOrCreateGitSource(tx, &portainer.Source{
|
||||
src, err := workflows.FindOrCreateGitSource(tx, &portainer.Source{
|
||||
Name: gittypes.RepoName(repoConfig.URL),
|
||||
Type: portainer.SourceTypeGit,
|
||||
GitConfig: &repoConfig,
|
||||
@@ -82,7 +83,16 @@ func (b *GitMethodStackBuilder) prepare(ctx context.Context, payload *StackPaylo
|
||||
}
|
||||
|
||||
wf := &portainer.Workflow{
|
||||
SourceIDs: []portainer.SourceID{src.ID},
|
||||
Name: b.stack.Name,
|
||||
Artifacts: []portainer.ArtifactSources{{
|
||||
Artifact: portainer.Artifact{
|
||||
ReferenceName: repoConfig.ReferenceName,
|
||||
ConfigFilePath: repoConfig.ConfigFilePath,
|
||||
ConfigHash: repoConfig.ConfigHash,
|
||||
StackID: b.stack.ID,
|
||||
},
|
||||
SourceIDs: []portainer.SourceID{src.ID},
|
||||
}},
|
||||
}
|
||||
if err := tx.Workflow().Create(wf); err != nil {
|
||||
return fmt.Errorf("failed to create workflow: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user