2015-12-17 16:07:04 -08:00
|
|
|
package supervisor
|
2015-12-01 10:55:13 -08:00
|
|
|
|
2016-02-11 17:26:24 -08:00
|
|
|
type GetContainersTask struct {
|
2015-12-01 10:55:13 -08:00
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
2016-02-11 17:26:24 -08:00
|
|
|
func (h *GetContainersTask) Handle(e *Task) error {
|
2016-02-11 12:20:29 -08:00
|
|
|
if e.ID != "" {
|
|
|
|
ci := h.s.containers[e.ID]
|
|
|
|
if ci == nil {
|
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
|
|
|
e.Containers = append(e.Containers, ci.container)
|
|
|
|
return nil
|
|
|
|
}
|
2015-12-11 11:27:33 -08:00
|
|
|
for _, i := range h.s.containers {
|
|
|
|
e.Containers = append(e.Containers, i.container)
|
2015-12-01 10:55:13 -08:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|