mirror of
https://github.com/containers/podman.git
synced 2025-08-06 03:19:52 +08:00
Add latest to wait
It is desirable to have a --latest switch on the podman wait command so we can wait on the latest container created to end. Also, fixes a panic with latest where no containers are available. Signed-off-by: baude <bbaude@redhat.com> Closes: #201 Approved by: baude
This commit is contained in:
@ -271,12 +271,15 @@ func (r *Runtime) GetContainersByList(containers []string) ([]*Container, error)
|
||||
|
||||
// GetLatestContainer returns a container object of the latest created container.
|
||||
func (r *Runtime) GetLatestContainer() (*Container, error) {
|
||||
var lastCreatedIndex int
|
||||
lastCreatedIndex := -1
|
||||
var lastCreatedTime time.Time
|
||||
ctrs, err := r.GetAllContainers()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to find latest container")
|
||||
}
|
||||
if len(ctrs) == 0 {
|
||||
return nil, ErrNoSuchCtr
|
||||
}
|
||||
for containerIndex, ctr := range ctrs {
|
||||
createdTime := ctr.config.CreatedTime
|
||||
if createdTime.After(lastCreatedTime) {
|
||||
|
Reference in New Issue
Block a user