MCPcopy Index your code
hub / github.com/ddev/ddev / ContainerCheck

Function ContainerCheck

pkg/testcommon/testcommon.go:372–388  ·  view source on GitHub ↗

ContainerCheck determines if a given container name exists and matches a given state

(checkName string, checkState string)

Source from the content-addressed store, hash-verified

370
371// ContainerCheck determines if a given container name exists and matches a given state
372func 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.

Callers 2

TestDdevStartFunction · 0.92

Calls 3

EnsureDdevNetworkFunction · 0.92
FindContainerByNameFunction · 0.92
ErrorfMethod · 0.80

Tested by 2

TestDdevStartFunction · 0.74