summaryrefslogtreecommitdiff
path: root/cmd/podman/image.go
blob: fb295b8a1611bfaf3773494b880ccc3a08be2e2a (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main

import (
	"strings"

	"github.com/containers/libpod/cmd/podman/cliconfig"
	"github.com/spf13/cobra"
)

var (
	imageDescription = "Manage images"
	imageCommand     = cliconfig.PodmanCommand{
		Command: &cobra.Command{
			Use:   "image",
			Short: "Manage images",
			Long:  imageDescription,
			RunE:  commandRunE(),
		},
	}
	imagesSubCommand  cliconfig.ImagesValues
	_imagesSubCommand = &cobra.Command{
		Use:     strings.Replace(_imagesCommand.Use, "images", "list", 1),
		Short:   _imagesCommand.Short,
		Long:    _imagesCommand.Long,
		Aliases: []string{"ls"},
		RunE: func(cmd *cobra.Command, args []string) error {
			imagesSubCommand.InputArgs = args
			imagesSubCommand.GlobalFlags = MainGlobalOpts
			return imagesCmd(&imagesSubCommand)
		},
		Example: strings.Replace(_imagesCommand.Example, "podman images", "podman image list", -1),
	}

	rmSubCommand  cliconfig.RmiValues
	_rmSubCommand = &cobra.Command{
		Use:   strings.Replace(_rmiCommand.Use, "rmi", "rm", 1),
		Short: _rmiCommand.Short,
		Long:  _rmiCommand.Long,
		RunE: func(cmd *cobra.Command, args []string) error {
			rmSubCommand.InputArgs = args
			rmSubCommand.GlobalFlags = MainGlobalOpts
			return rmiCmd(&rmSubCommand)
		},
		Example: strings.Replace(_rmiCommand.Example, "podman rmi", "podman image rm", -1),
	}
)

//imageSubCommands are implemented both in local and remote clients
var imageSubCommands = []*cobra.Command{
	_buildCommand,
	_historyCommand,
	_imagesSubCommand,
	_imageExistsCommand,
	_importCommand,
	_inspectCommand,
	_loadCommand,
	_pruneImagesCommand,
	_pullCommand,
	_pushCommand,
	_rmSubCommand,
	_saveCommand,
	_tagCommand,
	_treeCommand,
}

func init() {
	rmSubCommand.Command = _rmSubCommand
	rmiInit(&rmSubCommand)

	imagesSubCommand.Command = _imagesSubCommand
	imagesInit(&imagesSubCommand)

	imageCommand.SetUsageTemplate(UsageTemplate())
	imageCommand.AddCommand(imageSubCommands...)
	imageCommand.AddCommand(getImageSubCommands()...)

}