2017-01-13 06:08:09 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
gocontext "context"
|
2017-02-10 04:32:11 +00:00
|
|
|
"errors"
|
2017-01-13 06:08:09 +00:00
|
|
|
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
2017-02-09 07:31:26 +00:00
|
|
|
"github.com/docker/containerd/api/services/execution"
|
2017-01-13 06:08:09 +00:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var inspectCommand = cli.Command{
|
2017-01-25 06:16:13 +00:00
|
|
|
Name: "inspect",
|
|
|
|
Usage: "inspect a container",
|
|
|
|
ArgsUsage: "CONTAINER",
|
2017-01-13 06:08:09 +00:00
|
|
|
Action: func(context *cli.Context) error {
|
|
|
|
executionService, err := getExecutionService(context)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
id := context.Args().First()
|
|
|
|
if id == "" {
|
2017-02-10 04:32:11 +00:00
|
|
|
return errors.New("container id must be provided")
|
2017-01-13 06:08:09 +00:00
|
|
|
}
|
2017-02-02 22:40:23 +00:00
|
|
|
getResponse, err := executionService.GetContainer(gocontext.Background(),
|
2017-01-13 06:08:09 +00:00
|
|
|
&execution.GetContainerRequest{ID: id})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
listProcResponse, err := executionService.ListProcesses(gocontext.Background(),
|
2017-02-02 23:36:10 +00:00
|
|
|
&execution.ListProcessesRequest{ContainerID: id})
|
2017-01-13 06:08:09 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
dumper := spew.NewDefaultConfig()
|
|
|
|
dumper.Indent = "\t"
|
|
|
|
dumper.DisableMethods = true
|
|
|
|
dumper.DisablePointerAddresses = true
|
|
|
|
dumper.Dump(getResponse, listProcResponse)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|