From 5080a83242928414098b99e249fae7994ca15b32 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Fri, 29 May 2020 08:55:44 +0200 Subject: [PATCH] prevent "Tasks cannot be empty" error Signed-off-by: Nicolas De Loof --- ecs/pkg/amazon/list.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ecs/pkg/amazon/list.go b/ecs/pkg/amazon/list.go index 2515fffe9..0a5f4c176 100644 --- a/ecs/pkg/amazon/list.go +++ b/ecs/pkg/amazon/list.go @@ -17,10 +17,15 @@ func (c *client) ComposePs(ctx context.Context, project *compose.Project) error } w := tabwriter.NewWriter(os.Stdout, 20, 2, 3, ' ', 0) fmt.Fprintf(w, "Name\tState\tPorts\n") + defer w.Flush() + arns, err := c.api.ListTasks(ctx, cluster, project.Name) if err != nil { return err } + if len(arns) == 0 { + return nil + } tasks, err := c.api.DescribeTasks(ctx, cluster, arns...) if err != nil { @@ -49,7 +54,6 @@ func (c *client) ComposePs(ctx context.Context, project *compose.Project) error } fmt.Fprintf(w, "%s\t%s\t%s\n", s.Name, t.State, strings.Join(ports, ", ")) } - w.Flush() return nil }