2018-02-05 16:05:59 -05:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
2015-05-05 16:25:05 -04:00
|
|
|
|
2016-06-13 22:52:49 -04:00
|
|
|
import (
|
2017-03-30 16:52:40 -04:00
|
|
|
"github.com/docker/docker/container"
|
2016-06-13 22:52:49 -04:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
2015-05-05 16:25:05 -04:00
|
|
|
|
2017-03-30 23:01:41 -04:00
|
|
|
// ContainerWait waits until the given container is in a certain state
|
|
|
|
// indicated by the given condition. If the container is not found, a nil
|
2017-03-30 16:52:40 -04:00
|
|
|
// channel and non-nil error is returned immediately. If the container is
|
|
|
|
// found, a status result will be sent on the returned channel once the wait
|
|
|
|
// condition is met or if an error occurs waiting for the container (such as a
|
2017-03-30 23:01:41 -04:00
|
|
|
// context timeout or cancellation). On a successful wait, the exit code of the
|
2017-03-30 16:52:40 -04:00
|
|
|
// container is returned in the status with a non-nil Err() value.
|
2017-03-30 23:01:41 -04:00
|
|
|
func (daemon *Daemon) ContainerWait(ctx context.Context, name string, condition container.WaitCondition) (<-chan container.StateStatus, error) {
|
|
|
|
cntr, err := daemon.GetContainer(name)
|
2016-06-13 22:52:49 -04:00
|
|
|
if err != nil {
|
2017-03-30 16:52:40 -04:00
|
|
|
return nil, err
|
2016-06-13 22:52:49 -04:00
|
|
|
}
|
|
|
|
|
2017-03-30 23:01:41 -04:00
|
|
|
return cntr.Wait(ctx, condition), nil
|
2016-06-13 22:52:49 -04:00
|
|
|
}
|