support docker compose run
This commit is contained in:
@@ -55,6 +55,27 @@ func (wrapper *PluginWrapper) Deploy(ctx context.Context, filePaths []string, op
|
||||
return err
|
||||
}
|
||||
|
||||
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,
|
||||
}), 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
|
||||
}
|
||||
|
||||
// Down stop and remove containers
|
||||
func (wrapper *PluginWrapper) Remove(ctx context.Context, projectName string, filePaths []string, options libstack.Options) error {
|
||||
output, err := wrapper.command(newDownCommand(projectName, filePaths), options)
|
||||
@@ -208,6 +229,24 @@ func newUpCommand(filePaths []string, options upOptions) composeCommand {
|
||||
return newCommand(args, filePaths)
|
||||
}
|
||||
|
||||
type runOptions struct {
|
||||
remove bool
|
||||
args []string
|
||||
}
|
||||
|
||||
func newRunCommand(filePaths []string, serviceName string, options runOptions) composeCommand {
|
||||
args := []string{"run"}
|
||||
|
||||
if options.remove {
|
||||
args = append(args, "--rm")
|
||||
}
|
||||
|
||||
args = append(args, serviceName)
|
||||
args = append(args, options.args...)
|
||||
|
||||
return newCommand(args, filePaths)
|
||||
}
|
||||
|
||||
func newDownCommand(projectName string, filePaths []string) composeCommand {
|
||||
cmd := newCommand([]string{"down", "--remove-orphans"}, filePaths)
|
||||
cmd.WithProjectName(projectName)
|
||||
|
||||
Reference in New Issue
Block a user