فهرست منبع

prevent "Tasks cannot be empty" error

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 5 سال پیش
والد
کامیت
5080a83242
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      ecs/pkg/amazon/list.go

+ 5 - 1
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
 }