containerd/vendor/github.com/Microsoft/hcsshim/cmd/go-runhcs/runhcs_state.go
Justin Terry (VM) 7768ab1b5e Update runhcs-shim to use go-bindings
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-20 10:40:33 -07:00

21 lines
438 B
Go

package runhcs
import (
"context"
"encoding/json"
"fmt"
)
// State outputs the state of a container.
func (r *Runhcs) State(context context.Context, id string) (*ContainerState, error) {
data, err := cmdOutput(r.command(context, "state", id), true)
if err != nil {
return nil, fmt.Errorf("%s: %s", err, data)
}
var out ContainerState
if err := json.Unmarshal(data, &out); err != nil {
return nil, err
}
return &out, nil
}