1package runhcs
2
3import (
4	"context"
5	"encoding/json"
6
7	irunhcs "github.com/Microsoft/hcsshim/internal/runhcs"
8)
9
10// ContainerState is the representation of the containers state at the moment of
11// query.
12type ContainerState = irunhcs.ContainerState
13
14// List containers started by runhcs.
15//
16// Note: This is specific to the Runhcs.Root namespace provided in the global
17// settings.
18func (r *Runhcs) List(context context.Context) ([]*ContainerState, error) {
19	data, err := cmdOutput(r.command(context, "list", "--format=json"), false)
20	if err != nil {
21		return nil, err
22	}
23	var out []*ContainerState
24	if err := json.Unmarshal(data, &out); err != nil {
25		return nil, err
26	}
27	return out, nil
28}
29