Merge pull request #730 from aiordache/ecs_detached_up

Add detach flag to `compose up`
This commit is contained in:
Nicolas De loof 2020-10-07 17:23:56 +02:00 committed by GitHub
commit 005c6dcfe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 10 deletions

View File

@ -44,7 +44,7 @@ func newComposeService(ctx store.AciContext) aciComposeService {
}
}
func (cs *aciComposeService) Up(ctx context.Context, project *types.Project) error {
func (cs *aciComposeService) Up(ctx context.Context, project *types.Project, detach bool) error {
logrus.Debugf("Up on project with name %q", project.Name)
groupDefinition, err := convert.ToContainerGroup(ctx, cs.ctx, *project, cs.storageLogin)
addTag(&groupDefinition, composeContainerTag)

View File

@ -30,7 +30,7 @@ type composeService struct {
}
// Up executes the equivalent to a `compose up`
func (c *composeService) Up(context.Context, *types.Project) error {
func (c *composeService) Up(context.Context, *types.Project, bool) error {
return errdefs.ErrNotImplemented
}

View File

@ -26,7 +26,7 @@ import (
// Service manages a compose project
type Service interface {
// Up executes the equivalent to a `compose up`
Up(ctx context.Context, project *types.Project) error
Up(ctx context.Context, project *types.Project, detach bool) error
// Down executes the equivalent to a `compose down`
Down(ctx context.Context, projectName string) error
// Logs executes the equivalent to a `compose logs`

View File

@ -34,6 +34,7 @@ type composeOptions struct {
ConfigPaths []string
Environment []string
Format string
Detach bool
}
func (o *composeOptions) toProjectName() (string, error) {

View File

@ -40,7 +40,7 @@ func upCommand(contextType string) *cobra.Command {
upCmd.Flags().StringVar(&opts.WorkingDir, "workdir", "", "Work dir")
upCmd.Flags().StringArrayVarP(&opts.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
upCmd.Flags().StringArrayVarP(&opts.Environment, "environment", "e", []string{}, "Environment variables")
upCmd.Flags().BoolP("detach", "d", true, " Detached mode: Run containers in the background")
upCmd.Flags().BoolVarP(&opts.Detach, "detach", "d", false, " Detached mode: Run containers in the background")
if contextType == store.AciContextType {
upCmd.Flags().StringVar(&opts.DomainName, "domainname", "", "Container NIS domain name")
@ -68,8 +68,7 @@ func runUp(ctx context.Context, opts composeOptions) error {
if err != nil {
return "", err
}
return "", c.ComposeService().Up(ctx, project)
return "", c.ComposeService().Up(ctx, project, opts.Detach)
})
return err
}

View File

@ -40,7 +40,7 @@ import (
"golang.org/x/mod/semver"
)
func (e ecsLocalSimulation) Up(ctx context.Context, project *types.Project) error {
func (e ecsLocalSimulation) Up(ctx context.Context, project *types.Project, detach bool) error {
cmd := exec.Command("docker-compose", "version", "--short")
b := bytes.Buffer{}
b.WriteString("v")

View File

@ -26,7 +26,7 @@ import (
"github.com/compose-spec/compose-go/types"
)
func (b *ecsAPIService) Up(ctx context.Context, project *types.Project) error {
func (b *ecsAPIService) Up(ctx context.Context, project *types.Project, detach bool) error {
err := b.SDK.CheckRequirements(ctx, b.Region)
if err != nil {
return err
@ -58,7 +58,9 @@ func (b *ecsAPIService) Up(ctx context.Context, project *types.Project) error {
return err
}
}
if detach {
return nil
}
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
go func() {

View File

@ -131,7 +131,7 @@ func (cs *containerService) Delete(ctx context.Context, id string, request conta
type composeService struct{}
func (cs *composeService) Up(ctx context.Context, project *types.Project) error {
func (cs *composeService) Up(ctx context.Context, project *types.Project, detach bool) error {
fmt.Printf("Up command on project %q", project.Name)
return nil
}