fix: handle missing containers
continuous-integration/drone/push Build is passing Details

Closes coop-cloud/organising#198.
This commit is contained in:
decentral1se 2021-10-19 22:50:43 +02:00
parent 74bcb99c70
commit aec1e4520d
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 8 additions and 3 deletions

View File

@ -55,15 +55,20 @@ var appRunCommand = &cli.Command{
}
serviceName := c.Args().Get(1)
stackAndServiceName := fmt.Sprintf("%s_%s", app.StackName(), serviceName)
filters := filters.NewArgs()
filters.Add("name", fmt.Sprintf("%s_%s", app.StackName(), serviceName))
filters.Add("name", stackAndServiceName)
containers, err := cl.ContainerList(c.Context, types.ContainerListOptions{Filters: filters})
if err != nil {
logrus.Fatal(err)
}
if len(containers) > 1 {
logrus.Fatalf("expected 1 container but got %d", len(containers))
switch len(containers) {
case 0:
logrus.Fatalf("no containers matching '%s' found?", stackAndServiceName)
case 1:
logrus.Fatalf("expected 1 container matching '%s' but got %d", stackAndServiceName, len(containers))
}
cmd := c.Args().Slice()[2:]