prevent "Tasks cannot be empty" error

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-05-29 08:55:44 +02:00
parent 5783b63556
commit 5080a83242
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 5 additions and 1 deletions

View File

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