github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/cmd/podman/image.go (about)

     1  package main
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/containers/libpod/cmd/podman/cliconfig"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  var (
    11  	imageDescription = "Manage images"
    12  	imageCommand     = cliconfig.PodmanCommand{
    13  		Command: &cobra.Command{
    14  			Use:   "image",
    15  			Short: "Manage images",
    16  			Long:  imageDescription,
    17  			RunE:  commandRunE(),
    18  		},
    19  	}
    20  	imagesSubCommand  cliconfig.ImagesValues
    21  	_imagesSubCommand = &cobra.Command{
    22  		Use:     strings.Replace(_imagesCommand.Use, "images", "list", 1),
    23  		Short:   _imagesCommand.Short,
    24  		Long:    _imagesCommand.Long,
    25  		Aliases: []string{"ls"},
    26  		RunE: func(cmd *cobra.Command, args []string) error {
    27  			imagesSubCommand.InputArgs = args
    28  			imagesSubCommand.GlobalFlags = MainGlobalOpts
    29  			return imagesCmd(&imagesSubCommand)
    30  		},
    31  		Example: strings.Replace(_imagesCommand.Example, "podman images", "podman image list", -1),
    32  	}
    33  
    34  	inspectSubCommand  cliconfig.InspectValues
    35  	_inspectSubCommand = &cobra.Command{
    36  		Use:   strings.Replace(_inspectCommand.Use, "CONTAINER | ", "", 1),
    37  		Short: "Display the configuration of an image",
    38  		Long:  `Displays the low-level information on an image identified by name or ID.`,
    39  		RunE: func(cmd *cobra.Command, args []string) error {
    40  			inspectSubCommand.InputArgs = args
    41  			inspectSubCommand.GlobalFlags = MainGlobalOpts
    42  			return inspectCmd(&inspectSubCommand)
    43  		},
    44  		Example: `podman image inspect alpine`,
    45  	}
    46  
    47  	rmSubCommand  cliconfig.RmiValues
    48  	_rmSubCommand = &cobra.Command{
    49  		Use:   strings.Replace(_rmiCommand.Use, "rmi", "rm", 1),
    50  		Short: _rmiCommand.Short,
    51  		Long:  _rmiCommand.Long,
    52  		RunE: func(cmd *cobra.Command, args []string) error {
    53  			rmSubCommand.InputArgs = args
    54  			rmSubCommand.GlobalFlags = MainGlobalOpts
    55  			return rmiCmd(&rmSubCommand)
    56  		},
    57  		Example: strings.Replace(_rmiCommand.Example, "podman rmi", "podman image rm", -1),
    58  	}
    59  )
    60  
    61  //imageSubCommands are implemented both in local and remote clients
    62  var imageSubCommands = []*cobra.Command{
    63  	_buildCommand,
    64  	_historyCommand,
    65  	_imagesSubCommand,
    66  	_imageExistsCommand,
    67  	_importCommand,
    68  	_inspectSubCommand,
    69  	_loadCommand,
    70  	_pruneImagesCommand,
    71  	_pullCommand,
    72  	_pushCommand,
    73  	_rmSubCommand,
    74  	_saveCommand,
    75  	_tagCommand,
    76  	_treeCommand,
    77  	_untagCommand,
    78  }
    79  
    80  func init() {
    81  	rmSubCommand.Command = _rmSubCommand
    82  	rmiInit(&rmSubCommand)
    83  
    84  	imagesSubCommand.Command = _imagesSubCommand
    85  	imagesInit(&imagesSubCommand)
    86  
    87  	inspectSubCommand.Command = _inspectSubCommand
    88  	inspectInit(&inspectSubCommand)
    89  
    90  	imageCommand.SetUsageTemplate(UsageTemplate())
    91  	imageCommand.AddCommand(imageSubCommands...)
    92  	imageCommand.AddCommand(getImageSubCommands()...)
    93  
    94  }