// ContainerList return containers on the host.
433833
func ContainerList(args *model.ContainerListArgs) (infos []*model.ContainerListInfo, totalCount int, err error) {
	err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		var (
			containers []types.Container
			opts       = types.ContainerListOptions{Filters: filters.NewArgs()}
		)

		if args.Filter == "" {
			opts.All = true
		} else {
			opts.Filters.Add("status", args.Filter)
		}
		if args.Name != "" {
			opts.Filters.Add("name", args.Name)
		}

		containers, err = cli.ContainerList(ctx, opts)
		if err == nil {
			//sort.Slice(containers, func(i, j int) bool {
			//	return containers[i] < containers[j].Description.Hostname
			//})
			totalCount = len(containers)
			start, end := misc.Page(totalCount, args.PageIndex, args.PageSize)
			containers = containers[start:end]
			if length := len(containers); length > 0 {
				infos = make([]*model.ContainerListInfo, length)
				for i, c := range containers {
					infos[i] = model.NewContainerListInfo(c)
				}
			}
		}
		return
	})
	return
}
73562
func Containers() ([]*Container, error) {
	dc, err := getDockerClient()
	if err != nil {
		return nil, err
	}
	apictrs, err := dc.ListContainers(dockerclient.ListContainersOptions{All: true})
	if err != nil {
		return nil, err
	}
	resp := []*Container{}
	for _, apictr := range apictrs {
		ctr, err := dc.InspectContainer(apictr.ID)
		if err != nil {
			continue
		}
		resp = append(resp, &Container{ctr})
	}
	return resp, nil
}
79999
func hostport_list_from_zk(zc zk.ZK, containers_path, service_port string) ([]interface{}, error) {
	n, err := zk.Follow(zc, registry.Path(containers_path))
	if err != nil {
		return nil, err
	}

	all, err := n.VisitChildrenRecursive(func(z *zk.Node) bool {
		_, port := ParseHostPort(z.GetBasename())
		return port == service_port && z.IsLeaf()
	})
	if err != nil {
		return nil, err
	}

	list := make([]interface{}, 0)
	for _, c := range all {
		host, port := ParseHostPort(c.GetValueString())
		list = append(list, struct {
			Host string
			Port string
		}{
			Host: host,
			Port: port,
		})
	}
	return list, nil
}
510819
func (daemon *Daemon) CheckpointList(name string, config types.CheckpointListOptions) ([]types.Checkpoint, error) {
	var out []types.Checkpoint

	container, err := daemon.GetContainer(name)
	if err != nil {
		return nil, err
	}

	checkpointDir, err := getCheckpointDir(config.CheckpointDir, "", name, container.ID, container.CheckpointDir(), false)
	if err != nil {
		return nil, err
	}

	if err := os.MkdirAll(checkpointDir, 0755); err != nil {
		return nil, err
	}

	dirs, err := ioutil.ReadDir(checkpointDir)
	if err != nil {
		return nil, err
	}

	for _, d := range dirs {
		if !d.IsDir() {
			continue
		}
		cpt := types.Checkpoint{Name: d.Name()}
		out = append(out, cpt)
	}

	return out, nil
}
572195
func (s *Server) filterContainerList(filter *pb.ContainerFilter, origCtrList []*oci.Container) []*oci.Container {
	// Filter using container id and pod id first.
	if filter.Id != "" {
		id, err := s.CtrIDIndex().Get(filter.Id)
		if err != nil {
			// If we don't find a container ID with a filter, it should not
			// be considered an error.  Log a warning and return an empty struct
			logrus.Warnf("unable to find container ID %s", filter.Id)
			return []*oci.Container{}
		}
		c := s.ContainerServer.GetContainer(id)
		if c != nil {
			switch {
			case filter.PodSandboxId == "":
				return []*oci.Container{c}
			case c.Sandbox() == filter.PodSandboxId:
				return []*oci.Container{c}
			default:
				return []*oci.Container{}
			}
		}
	} else if filter.PodSandboxId != "" {
		pod := s.ContainerServer.GetSandbox(filter.PodSandboxId)
		if pod == nil {
			return []*oci.Container{}
		}
		return pod.Containers().List()
	}
	logrus.Debug("no filters were applied, returning full container list")
	return origCtrList
}
1068069
func (dh *Client) Containers() (containers []*docker.Container, e error) {
	return dh.ListContainers(nil)
}
1019153
func (s *persistentVolumeLister) List(selector labels.Selector) (ret []*v1.PersistentVolume, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.PersistentVolume))
	})
	return ret, err
}
212692
func (cli *Client) PluginList(ctx context.Context) (types.PluginsListResponse, error) {
	var plugins types.PluginsListResponse
	resp, err := cli.get(ctx, "/plugins", nil, nil)
	if err != nil {
		return plugins, err
	}

	err = json.NewDecoder(resp.body).Decode(&plugins)
	ensureReaderClosed(resp)
	return plugins, err
}
889484
func (v *Vibranium) ListContainers(ctx context.Context, opts *pb.ListContainersOptions) (*pb.Containers, error) {
	lsopts := &types.ListContainersOptions{
		Appname:    opts.Appname,
		Entrypoint: opts.Entrypoint,
		Nodename:   opts.Nodename,
	}
	containers, err := v.cluster.ListContainers(ctx, lsopts)
	if err != nil {
		return nil, err
	}

	return &pb.Containers{Containers: toRPCContainers(ctx, containers, opts.Labels)}, nil
}
717623
func (s *ciliumEndpointLister) List(selector labels.Selector) (ret []*v2.CiliumEndpoint, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v2.CiliumEndpoint))
	})
	return ret, err
}
40531
func (f FakeClusterLister) List() (*containerservice.ListResult, error) {
	return f.Resp, f.Err
}
184395
func (r *CRIO) ListContainers(filter string) ([]string, error) {
	return listCRIContainers(r.Runner, filter)
}
103818
func (r Network_Storage_Hub_Swift_Share) GetContainerList() (resp []datatypes.Container_Network_Storage_Hub_ObjectStorage_Folder, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Storage_Hub_Swift_Share", "getContainerList", nil, &r.Options, &resp)
	return
}
292261
func (s podNamespaceLister) List(selector labels.Selector) (ret []*v1.Pod, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v1.Pod))
	})
	return ret, err
}
291060
func (r *RemoteRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error) {
	ctx, cancel := getContextWithTimeout(r.timeout)
	defer cancel()

	resp, err := r.runtimeClient.ListContainers(ctx, &runtimeapi.ListContainersRequest{
		Filter: filter,
	})
	if err != nil {
		klog.Errorf("ListContainers with filter %+v from runtime service failed: %v", filter, err)
		return nil, err
	}

	return resp.Containers, nil
}
912350
func (c *horizontalPodAutoscalers) List(opts api.ListOptions) (result *extensions.HorizontalPodAutoscalerList, err error) {
	result = &extensions.HorizontalPodAutoscalerList{}
	err = c.client.Get().Namespace(c.ns).Resource("horizontalPodAutoscalers").VersionedParams(&opts, api.Scheme).Do().Into(result)
	return
}
870702
func (r *Docker) ListContainers(filter string) ([]string, error) {
	content, err := r.Runner.CombinedOutput(fmt.Sprintf(`docker ps -a --filter="name=%s" --format="{{.ID}}"`, filter))
	if err != nil {
		return nil, err
	}
	var ids []string
	for _, line := range strings.Split(content, "\n") {
		if line != "" {
			ids = append(ids, line)
		}
	}
	return ids, nil
}