ContainerCheck determines if a given container name exists and matches a given state
(checkName string, checkState string)
| 370 | |
| 371 | // ContainerCheck determines if a given container name exists and matches a given state |
| 372 | func ContainerCheck(checkName string, checkState string) (bool, error) { |
| 373 | // Ensure we have DDEV network |
| 374 | dockerutil.EnsureDdevNetwork() |
| 375 | |
| 376 | c, err := dockerutil.FindContainerByName(checkName) |
| 377 | if err != nil { |
| 378 | output.UserErr.Fatal(err) |
| 379 | } |
| 380 | if c == nil { |
| 381 | return false, fmt.Errorf("unable to find container %s", checkName) |
| 382 | } |
| 383 | |
| 384 | if string(c.State) == checkState { |
| 385 | return true, nil |
| 386 | } |
| 387 | return false, fmt.Errorf("container %s returned %s", checkName, c.State) |
| 388 | } |
| 389 | |
| 390 | // GetCachedArchive returns a directory populated with the contents of the specified archive, either from cache or |
| 391 | // from downloading and creating cache. |