containerd/cmd/ctr/info.go
Michael Crosby 00288bcb58 Update ctr containers and tasks command
This moves container and tasks commands under the containers and tasks
top level commands.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-07 14:45:21 -04:00

42 lines
761 B
Go

package main
import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
var containerInfoCommand = cli.Command{
Name: "info",
Usage: "get info about a container",
ArgsUsage: "CONTAINER",
Action: func(context *cli.Context) error {
var (
ctx, cancel = appContext(context)
id = context.Args().First()
)
defer cancel()
if id == "" {
return errors.New("container id must be provided")
}
client, err := newClient(context)
if err != nil {
return err
}
container, err := client.LoadContainer(ctx, id)
if err != nil {
return err
}
cjson, err := json.MarshalIndent(container.Info(), "", " ")
if err != nil {
return err
}
fmt.Println(string(cjson))
return nil
},
}