forked from containerd/containerd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.go
41 lines (36 loc) · 752 Bytes
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
var infoCommand = 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
},
}