Init progress writer in WaitStackCompletion

Signed-off-by: aiordache <anca.iordache@docker.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
aiordache 2020-08-14 12:01:22 +02:00 committed by Nicolas De Loof
parent f74cc8f0aa
commit 9eb0a10517
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
3 changed files with 3 additions and 12 deletions

View File

@ -82,7 +82,6 @@ func UpCommand(dockerCli command.Cli, options *composeOptions) *cobra.Command {
}
return progress.Run(context.Background(), func(ctx context.Context) error {
backend.SetWriter(ctx)
return backend.Up(ctx, opts)
})
}),
@ -130,7 +129,6 @@ func DownCommand(dockerCli command.Cli, options *composeOptions) *cobra.Command
return err
}
return progress.Run(context.Background(), func(ctx context.Context) error {
backend.SetWriter(ctx)
return backend.Down(ctx, opts)
})
}),

View File

@ -1,12 +1,9 @@
package backend
import (
"context"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/docker/ecs-plugin/pkg/amazon/sdk"
"github.com/docker/ecs-plugin/pkg/progress"
)
func NewBackend(profile string, region string) (*Backend, error) {
@ -30,9 +27,4 @@ func NewBackend(profile string, region string) (*Backend, error) {
type Backend struct {
Region string
api sdk.API
writer progress.Writer
}
func (b *Backend) SetWriter(context context.Context) {
b.writer = progress.ContextWriter(context)
}

View File

@ -14,7 +14,8 @@ import (
func (b *Backend) WaitStackCompletion(ctx context.Context, name string, operation int) error {
knownEvents := map[string]struct{}{}
// progress writer
w := progress.ContextWriter(ctx)
// Get the unique Stack ID so we can collect events without getting some from previous deployments with same name
stackID, err := b.api.GetStackID(ctx, name)
if err != nil {
@ -80,7 +81,7 @@ func (b *Backend) WaitStackCompletion(ctx context.Context, name string, operatio
}
}
}
b.writer.Event(progress.Event{
w.Event(progress.Event{
ID: resource,
Status: progressStatus,
StatusText: status,