mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(stack-details): Add the ability to duplicate a stack (#2278)
* feat(stack-details): add duplicate-stack button * feat(stack-details): add stack-duplication-form component * feat(stack-details): add duplicate stack method on controller * feat(stack-details): add duplicate stack method * feat(stack-details): remove old duplication in progress flag * feat(stack-details): combine migration and duplication forms * feat(stack-details): pass new stack name to server * feat(stack-details): add option to rename migrated stack * feat(stack-details): disable both migrate/duplicate buttons * feat(stack-details): disable migration button on same endpoint * feat(stack-details): change duplicate icon * style(stack-details): remove whitespaces and fix pattern * feat(stack-details): add name to migration payload in swagger.yml * style(stack-details): add semicolon * bug(stack-details): toggle endpoints before and after duplication
This commit is contained in:
parent
6e262e6e89
commit
9b4870d57e
8 changed files with 205 additions and 54 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
type stackMigratePayload struct {
|
||||
EndpointID int
|
||||
SwarmID string
|
||||
Name string
|
||||
}
|
||||
|
||||
func (payload *stackMigratePayload) Validate(r *http.Request) error {
|
||||
|
@ -89,11 +90,17 @@ func (handler *Handler) stackMigrate(w http.ResponseWriter, r *http.Request) *ht
|
|||
stack.SwarmID = payload.SwarmID
|
||||
}
|
||||
|
||||
oldName := stack.Name
|
||||
if payload.Name != "" {
|
||||
stack.Name = payload.Name
|
||||
}
|
||||
|
||||
migrationError := handler.migrateStack(r, stack, targetEndpoint)
|
||||
if migrationError != nil {
|
||||
return migrationError
|
||||
}
|
||||
|
||||
stack.Name = oldName
|
||||
err = handler.deleteStack(stack, endpoint)
|
||||
if err != nil {
|
||||
return &httperror.HandlerError{http.StatusInternalServerError, err.Error(), err}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue