mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
refactor(stack): stack build process backend only [EE-4342] (#7750)
This commit is contained in:
parent
83a1ce9d2a
commit
e9de484c3e
65 changed files with 2270 additions and 942 deletions
|
@ -11,7 +11,8 @@ import (
|
|||
portainer "github.com/portainer/portainer/api"
|
||||
httperrors "github.com/portainer/portainer/api/http/errors"
|
||||
"github.com/portainer/portainer/api/http/security"
|
||||
"github.com/portainer/portainer/api/internal/stackutils"
|
||||
"github.com/portainer/portainer/api/stacks/deployments"
|
||||
"github.com/portainer/portainer/api/stacks/stackutils"
|
||||
)
|
||||
|
||||
type stackMigratePayload struct {
|
||||
|
@ -189,26 +190,53 @@ func (handler *Handler) migrateStack(r *http.Request, stack *portainer.Stack, ne
|
|||
}
|
||||
|
||||
func (handler *Handler) migrateComposeStack(r *http.Request, stack *portainer.Stack, next *portainer.Endpoint) *httperror.HandlerError {
|
||||
config, configErr := handler.createComposeDeployConfig(r, stack, next, false)
|
||||
if configErr != nil {
|
||||
return configErr
|
||||
// Create compose deployment config
|
||||
securityContext, err := security.RetrieveRestrictedRequestContext(r)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to retrieve info from request context", err)
|
||||
}
|
||||
|
||||
err := handler.deployComposeStack(config, false)
|
||||
composeDeploymentConfig, err := deployments.CreateComposeStackDeploymentConfig(securityContext,
|
||||
stack,
|
||||
next,
|
||||
handler.DataStore,
|
||||
handler.FileService,
|
||||
handler.StackDeployer,
|
||||
false,
|
||||
false)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError(err.Error(), err)
|
||||
}
|
||||
|
||||
// Deploy the stack
|
||||
err = composeDeploymentConfig.Deploy()
|
||||
if err != nil {
|
||||
return httperror.InternalServerError(err.Error(), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (handler *Handler) migrateSwarmStack(r *http.Request, stack *portainer.Stack, next *portainer.Endpoint) *httperror.HandlerError {
|
||||
config, configErr := handler.createSwarmDeployConfig(r, stack, next, true, true)
|
||||
if configErr != nil {
|
||||
return configErr
|
||||
// Create swarm deployment config
|
||||
securityContext, err := security.RetrieveRestrictedRequestContext(r)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to retrieve info from request context", err)
|
||||
}
|
||||
|
||||
err := handler.deploySwarmStack(config)
|
||||
swarmDeploymentConfig, err := deployments.CreateSwarmStackDeploymentConfig(securityContext,
|
||||
stack,
|
||||
next,
|
||||
handler.DataStore,
|
||||
handler.FileService,
|
||||
handler.StackDeployer,
|
||||
true,
|
||||
true)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError(err.Error(), err)
|
||||
}
|
||||
|
||||
// Deploy the stack
|
||||
err = swarmDeploymentConfig.Deploy()
|
||||
if err != nil {
|
||||
return httperror.InternalServerError(err.Error(), err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue