mirror of https://github.com/docker/compose.git
Simplify command setup
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
0e319ae65a
commit
8259604074
|
@ -20,10 +20,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/cli"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/docker/compose-cli/api/client"
|
|
||||||
"github.com/docker/compose-cli/api/compose"
|
"github.com/docker/compose-cli/api/compose"
|
||||||
"github.com/docker/compose-cli/api/containers"
|
"github.com/docker/compose-cli/api/containers"
|
||||||
"github.com/docker/compose-cli/progress"
|
"github.com/docker/compose-cli/progress"
|
||||||
|
@ -69,24 +67,11 @@ func runRun(ctx context.Context, opts runOptions) error {
|
||||||
WorkingDir: opts.WorkingDir,
|
WorkingDir: opts.WorkingDir,
|
||||||
Environment: opts.Environment,
|
Environment: opts.Environment,
|
||||||
}
|
}
|
||||||
options, err := projectOpts.toProjectOptions()
|
c, project, err := setup(ctx, projectOpts, []string{opts.Name})
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
project, err := cli.ProjectFromOptions(options)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = filter(project, []string{opts.Name})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err := client.NewWithDefaultLocalBackend(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
containerID, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
|
containerID, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||||
return c.ComposeService().CreateOneOffContainer(ctx, project, compose.RunOptions{
|
return c.ComposeService().CreateOneOffContainer(ctx, project, compose.RunOptions{
|
||||||
Name: opts.Name,
|
Name: opts.Name,
|
||||||
|
|
Loading…
Reference in New Issue