get_containers.go 498 B

1234567891011121314151617181920212223242526272829
  1. package supervisor
  2. import "github.com/docker/containerd/runtime"
  3. type GetContainersTask struct {
  4. baseTask
  5. ID string
  6. Containers []runtime.Container
  7. }
  8. func (s *Supervisor) getContainers(t *GetContainersTask) error {
  9. if t.ID != "" {
  10. ci, ok := s.containers[t.ID]
  11. if !ok {
  12. return ErrContainerNotFound
  13. }
  14. t.Containers = append(t.Containers, ci.container)
  15. return nil
  16. }
  17. for _, ci := range s.containers {
  18. t.Containers = append(t.Containers, ci.container)
  19. }
  20. return nil
  21. }