2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-12-01 18:55:13 +00:00
|
|
|
|
2016-02-12 01:26:24 +00:00
|
|
|
type GetContainersTask struct {
|
2015-12-01 18:55:13 +00:00
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
2016-02-12 01:26:24 +00:00
|
|
|
func (h *GetContainersTask) Handle(e *Task) error {
|
2016-02-11 20:20:29 +00: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 19:27:33 +00:00
|
|
|
for _, i := range h.s.containers {
|
|
|
|
e.Containers = append(e.Containers, i.container)
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|