github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/cmd/podmanV2/inspect.go (about) 1 package main 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/containers/libpod/cmd/podmanV2/common" 8 "github.com/containers/libpod/cmd/podmanV2/containers" 9 "github.com/containers/libpod/cmd/podmanV2/images" 10 "github.com/containers/libpod/cmd/podmanV2/registry" 11 "github.com/containers/libpod/pkg/domain/entities" 12 "github.com/spf13/cobra" 13 ) 14 15 // Inspect is one of the outlier commands in that it operates on images/containers/... 16 17 var ( 18 inspectOpts *entities.InspectOptions 19 20 // Command: podman _inspect_ Object_ID 21 inspectCmd = &cobra.Command{ 22 Use: "inspect [flags] {CONTAINER_ID | IMAGE_ID}", 23 Args: cobra.ExactArgs(1), 24 Short: "Display the configuration of object denoted by ID", 25 Long: "Displays the low-level information on an object identified by name or ID", 26 TraverseChildren: true, 27 RunE: inspect, 28 } 29 ) 30 31 func init() { 32 registry.Commands = append(registry.Commands, registry.CliCommand{ 33 Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, 34 Command: inspectCmd, 35 }) 36 inspectOpts = common.AddInspectFlagSet(inspectCmd) 37 } 38 39 func inspect(cmd *cobra.Command, args []string) error { 40 ie, err := registry.NewImageEngine(cmd, args) 41 if err != nil { 42 return err 43 } 44 45 if found, err := ie.Exists(context.Background(), args[0]); err != nil { 46 return err 47 } else if found.Value { 48 return images.Inspect(cmd, args, inspectOpts) 49 } 50 51 ce, err := registry.NewContainerEngine(cmd, args) 52 if err != nil { 53 return err 54 } 55 56 if found, err := ce.ContainerExists(context.Background(), args[0]); err != nil { 57 return err 58 } else if found.Value { 59 return containers.Inspect(cmd, args, inspectOpts) 60 } 61 return fmt.Errorf("%s not found on system", args[0]) 62 }