1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 14:29:40 +02:00

feat(system): upgrade on swarm [EE-5848] (#11728)

Co-authored-by: Chaim Lev-Ari <chaim.levi-ari@portainer.io>
Co-authored-by: LP B <xAt0mZ@users.noreply.github.com>
This commit is contained in:
Chaim Lev-Ari 2024-09-20 19:00:38 +03:00 committed by GitHub
parent 3cb484f06a
commit 6f84317e7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 362 additions and 158 deletions

View file

@ -158,11 +158,12 @@ func (wrapper *PluginWrapper) command(command composeCommand, options libstack.O
cmd.Env = append(cmd.Env, options.Env...)
executedCommand := cmd.String()
log.Debug().
Str("command", program).
Strs("args", args).
Str("command", executedCommand).
Interface("env", cmd.Env).
Msg("run command")
Msg("execute command")
cmd.Stderr = &stderr

View file

@ -0,0 +1,53 @@
package composeplugin
import (
"context"
"github.com/portainer/portainer/pkg/libstack"
"github.com/rs/zerolog/log"
)
func (wrapper *PluginWrapper) Run(ctx context.Context, filePaths []string, serviceName string, options libstack.RunOptions) error {
output, err := wrapper.command(newRunCommand(filePaths, serviceName, runOptions{
remove: options.Remove,
args: options.Args,
detached: options.Detached,
}), options.Options)
if len(output) != 0 {
if err != nil {
return err
}
log.Info().Msg("Stack run successful")
log.Debug().
Str("output", string(output)).
Msg("docker compose")
}
return err
}
type runOptions struct {
remove bool
args []string
detached bool
}
func newRunCommand(filePaths []string, serviceName string, options runOptions) composeCommand {
args := []string{"run"}
if options.remove {
args = append(args, "--rm")
}
if options.detached {
args = append(args, "-d")
}
args = append(args, serviceName)
args = append(args, options.args...)
return newCommand(args, filePaths)
}