فهرست منبع

Init progress writer in WaitStackCompletion

Signed-off-by: aiordache <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
aiordache 5 سال پیش
والد
کامیت
9eb0a10517
3فایلهای تغییر یافته به همراه3 افزوده شده و 12 حذف شده
  1. 0 2
      ecs/cmd/commands/compose.go
  2. 0 8
      ecs/pkg/amazon/backend/backend.go
  3. 3 2
      ecs/pkg/amazon/backend/wait.go

+ 0 - 2
ecs/cmd/commands/compose.go

@@ -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)
 			})
 		}),

+ 0 - 8
ecs/pkg/amazon/backend/backend.go

@@ -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)
 }

+ 3 - 2
ecs/pkg/amazon/backend/wait.go

@@ -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,