2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-12-01 18:55:13 +00:00
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
import "github.com/docker/containerd/runtime"
|
|
|
|
|
2016-06-03 22:00:49 +00:00
|
|
|
// GetContainersTask holds needed parameters to retrieve a list of
|
|
|
|
// containers
|
2016-02-12 01:26:24 +00:00
|
|
|
type GetContainersTask struct {
|
2016-02-17 18:55:54 +00:00
|
|
|
baseTask
|
|
|
|
ID string
|
|
|
|
Containers []runtime.Container
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
func (s *Supervisor) getContainers(t *GetContainersTask) error {
|
2016-04-22 21:29:30 +00:00
|
|
|
|
2016-02-17 18:55:54 +00:00
|
|
|
if t.ID != "" {
|
2016-04-22 21:29:30 +00:00
|
|
|
ci, ok := s.containers[t.ID]
|
|
|
|
if !ok {
|
2016-02-11 20:20:29 +00:00
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
2016-02-17 18:55:54 +00:00
|
|
|
t.Containers = append(t.Containers, ci.container)
|
2016-04-22 21:29:30 +00:00
|
|
|
|
2016-02-11 20:20:29 +00:00
|
|
|
return nil
|
|
|
|
}
|
2016-04-22 21:29:30 +00:00
|
|
|
|
|
|
|
for _, ci := range s.containers {
|
|
|
|
t.Containers = append(t.Containers, ci.container)
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
2016-04-22 21:29:30 +00:00
|
|
|
|
2015-12-01 18:55:13 +00:00
|
|
|
return nil
|
|
|
|
}
|