2015-12-17 16:07:04 -08:00
|
|
|
package supervisor
|
2015-12-01 10:55:13 -08:00
|
|
|
|
2016-02-17 10:55:54 -08:00
|
|
|
import "github.com/docker/containerd/runtime"
|
|
|
|
|
2016-02-11 17:26:24 -08:00
|
|
|
type GetContainersTask struct {
|
2016-02-17 10:55:54 -08:00
|
|
|
baseTask
|
|
|
|
ID string
|
|
|
|
Containers []runtime.Container
|
2015-12-01 10:55:13 -08:00
|
|
|
}
|
|
|
|
|
2016-02-17 10:55:54 -08:00
|
|
|
func (s *Supervisor) getContainers(t *GetContainersTask) error {
|
|
|
|
if t.ID != "" {
|
|
|
|
ci := s.containers[t.ID]
|
2016-02-11 12:20:29 -08:00
|
|
|
if ci == nil {
|
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
2016-02-17 10:55:54 -08:00
|
|
|
t.Containers = append(t.Containers, ci.container)
|
2016-02-11 12:20:29 -08:00
|
|
|
return nil
|
|
|
|
}
|
2016-02-17 10:55:54 -08:00
|
|
|
for _, i := range s.containers {
|
|
|
|
t.Containers = append(t.Containers, i.container)
|
2015-12-01 10:55:13 -08:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|