forked from containers/podman
/
inspect.go
47 lines (41 loc) · 1.65 KB
/
inspect.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
42
43
44
45
46
47
package containers
import (
"github.com/hanks177/podman/v4/cmd/podman/common"
"github.com/hanks177/podman/v4/cmd/podman/inspect"
"github.com/hanks177/podman/v4/cmd/podman/registry"
"github.com/hanks177/podman/v4/cmd/podman/validate"
"github.com/hanks177/podman/v4/libpod/define"
"github.com/hanks177/podman/v4/pkg/domain/entities"
"github.com/spf13/cobra"
)
var (
// podman container _inspect_
inspectCmd = &cobra.Command{
Use: "inspect [options] CONTAINER [CONTAINER...]",
Short: "Display the configuration of a container",
Long: `Displays the low-level information on a container identified by name or ID.`,
RunE: inspectExec,
ValidArgsFunction: common.AutocompleteContainers,
Example: `podman container inspect myCtr
podman container inspect -l --format '{{.Id}} {{.Config.Labels}}'`,
}
inspectOpts *entities.InspectOptions
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: inspectCmd,
Parent: containerCmd,
})
inspectOpts = new(entities.InspectOptions)
flags := inspectCmd.Flags()
flags.BoolVarP(&inspectOpts.Size, "size", "s", false, "Display total file size")
formatFlagName := "format"
flags.StringVarP(&inspectOpts.Format, formatFlagName, "f", "json", "Format the output to a Go template or json")
_ = inspectCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(&define.InspectContainerData{}))
validate.AddLatestFlag(inspectCmd, &inspectOpts.Latest)
}
func inspectExec(cmd *cobra.Command, args []string) error {
// Force container type
inspectOpts.Type = common.ContainerType
return inspect.Inspect(args, *inspectOpts)
}