Merge pull request #4081 from crosbymichael/info-spec

Add ctr c info --spec flag to output spec
This commit is contained in:
Maksym Pavlenko
2020-03-05 09:54:41 -08:00
committed by GitHub

View File

@@ -248,6 +248,12 @@ var infoCommand = cli.Command{
Name: "info", Name: "info",
Usage: "get info about a container", Usage: "get info about a container",
ArgsUsage: "CONTAINER", ArgsUsage: "CONTAINER",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "spec",
Usage: "only display the spec",
},
},
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
id := context.Args().First() id := context.Args().First()
if id == "" { if id == "" {
@@ -266,6 +272,14 @@ var infoCommand = cli.Command{
if err != nil { if err != nil {
return err return err
} }
if context.Bool("spec") {
v, err := typeurl.UnmarshalAny(info.Spec)
if err != nil {
return err
}
commands.PrintAsJSON(v)
return nil
}
if info.Spec != nil && info.Spec.Value != nil { if info.Spec != nil && info.Spec.Value != nil {
v, err := typeurl.UnmarshalAny(info.Spec) v, err := typeurl.UnmarshalAny(info.Spec)