refactor(stack): change stack creation flow to save stack first [BE-12650] (#1959)

This commit is contained in:
Oscar Zhou
2026-02-27 10:14:17 +13:00
committed by GitHub
parent 56a840e207
commit 5869a8948d
15 changed files with 127 additions and 60 deletions
@@ -4,7 +4,6 @@ import (
"time"
portainer "github.com/portainer/portainer/api"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)
type UrlMethodStackBuildProcess interface {
@@ -15,11 +14,12 @@ type UrlMethodStackBuildProcess interface {
// Deploy stack based on the configuration
Deploy(payload *StackPayload, endpoint *portainer.Endpoint) UrlMethodStackBuildProcess
// Save the stack information to database
SaveStack() (*portainer.Stack, *httperror.HandlerError)
SaveStack() (*portainer.Stack, error)
// Get reponse from http request. Use if it is needed
GetResponse() string
// Set manifest url
SetURL(payload *StackPayload) UrlMethodStackBuildProcess
Error() error
}
type UrlMethodStackBuilder struct {
@@ -55,7 +55,7 @@ func (b *UrlMethodStackBuilder) Deploy(payload *StackPayload, endpoint *portaine
// Deploy the stack
err := b.deploymentConfiger.Deploy()
if err != nil {
b.err = httperror.InternalServerError(err.Error(), err)
b.err = err
return b
}
@@ -65,3 +65,7 @@ func (b *UrlMethodStackBuilder) Deploy(payload *StackPayload, endpoint *portaine
func (b *UrlMethodStackBuilder) GetResponse() string {
return ""
}
func (b *UrlMethodStackBuilder) Error() error {
return b.err
}