[Techinal Debt] Cleanup ABI vs. Tunnel CLI commands

[NO TESTS NEEDED]

This commit cleans up two issues:
* Most commands support all EngineModes so default to that. Let
  outlayers declare their intent.
* Use cobra.Annotations to set supported EngineMode. This simplies
  instantiating commands as there is now one method to communicate a
  commands requirements rather than two.
* Combined aliased commands into one file
* Fixed aliased commands where Args field did not match
* Updated examples in README.md for writing commands
* Remove redundant flag DisableFlagsInUseLine in cobra.Command
  initialization.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce 2021-05-18 11:23:25 -07:00
parent 4f4a440afd
commit 33944cefe7
148 changed files with 266 additions and 509 deletions

View File

@ -40,9 +40,6 @@ var (
func init() {
// Subscribe command to podman
registry.Commands = append(registry.Commands, registry.CliCommand{
// _podman manifest_ will support both ABIMode and TunnelMode
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
// The definition for this command
Command: manifestCmd,
})
}
@ -83,9 +80,6 @@ var (
func init() {
// Subscribe inspect sub command to manifest command
registry.Commands = append(registry.Commands, registry.CliCommand{
// _podman manifest inspect_ will support both ABIMode and TunnelMode
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
// The definition for this command
Command: inspectCmd,
// The parent command to proceed this command on the CLI
Parent: manifestCmd,

View File

@ -21,6 +21,7 @@ var (
or similar units that create new containers in order to run the updated images.
Please refer to the podman-auto-update(1) man page for details.`
autoUpdateCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "auto-update [options]",
Short: "Auto update containers according to their auto-update policy",
Long: autoUpdateDescription,
@ -33,7 +34,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: autoUpdateCommand,
})

View File

@ -8,7 +8,6 @@ import (
commonComp "github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -39,7 +38,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: completionCmd,
})
flags := completionCmd.Flags()

View File

@ -55,14 +55,12 @@ func attachFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: attachCommand,
})
attachFlags(attachCommand)
validate.AddLatestFlag(attachCommand, &attachOpts.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerAttachCommand,
Parent: containerCmd,
})

View File

@ -42,7 +42,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: checkpointCommand,
Parent: containerCmd,
})

View File

@ -21,6 +21,7 @@ var (
Cleans up mount points and network stacks on one or more containers from the host. The container name or ID can be used. This command is used internally when running containers, but can also be used if container cleanup has failed when a container exits.
`
cleanupCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "cleanup [options] CONTAINER [CONTAINER...]",
Short: "Cleanup network and mountpoints of one or more containers",
Long: cleanupDescription,
@ -41,7 +42,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Parent: containerCmd,
Command: cleanupCommand,
})

View File

@ -82,13 +82,11 @@ func commitFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: commitCommand,
})
commitFlags(commitCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerCommitCommand,
Parent: containerCmd,
})

View File

@ -3,7 +3,6 @@ package containers
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/util"
"github.com/spf13/cobra"
)
@ -26,7 +25,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerCmd,
})
}

View File

@ -62,13 +62,11 @@ func cpFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: cpCommand,
})
cpFlags(cpCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerCpCommand,
Parent: containerCmd,
})

View File

@ -39,7 +39,7 @@ var (
}
containerCreateCommand = &cobra.Command{
Args: cobra.MinimumNArgs(1),
Args: createCommand.Args,
Use: createCommand.Use,
Short: createCommand.Short,
Long: createCommand.Long,
@ -72,13 +72,11 @@ func createFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: createCommand,
})
createFlags(createCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerCreateCommand,
Parent: containerCmd,
})

View File

@ -27,7 +27,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: diffCmd,
Parent: containerCmd,
})

View File

@ -25,7 +25,6 @@ var (
Short: "Run a process in a running container",
Long: execDescription,
RunE: exec,
DisableFlagsInUseLine: true,
ValidArgsFunction: common.AutocompleteExecCommand,
Example: `podman exec -it ctrID ls
podman exec -it -w /tmp myCtr pwd
@ -37,7 +36,6 @@ var (
Short: execCommand.Short,
Long: execCommand.Long,
RunE: execCommand.RunE,
DisableFlagsInUseLine: true,
ValidArgsFunction: execCommand.ValidArgsFunction,
Example: `podman container exec -it ctrID ls
podman container exec -it -w /tmp myCtr pwd
@ -92,14 +90,12 @@ func execFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: execCommand,
})
execFlags(execCommand)
validate.AddLatestFlag(execCommand, &execOpts.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerExecCommand,
Parent: containerCmd,
})

View File

@ -20,14 +20,12 @@ var (
podman container exists myctr || podman run --name myctr [etc...]`,
RunE: exists,
Args: cobra.ExactArgs(1),
DisableFlagsInUseLine: true,
ValidArgsFunction: common.AutocompleteContainers,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: existsCommand,
Parent: containerCmd,
})

View File

@ -55,13 +55,11 @@ func exportFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: exportCommand,
})
exportFlags(exportCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerExportCommand,
Parent: containerCmd,
})

View File

@ -52,7 +52,6 @@ func initFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: initCommand,
})
flags := initCommand.Flags()
@ -60,7 +59,6 @@ func init() {
validate.AddLatestFlag(initCommand, &initOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Parent: containerCmd,
Command: containerInitCommand,
})

View File

@ -26,7 +26,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: inspectCmd,
Parent: containerCmd,
})

View File

@ -67,14 +67,12 @@ func killFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: killCommand,
})
killFlags(killCommand)
validate.AddLatestFlag(killCommand, &killOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerKillCommand,
Parent: containerCmd,
})

View File

@ -4,7 +4,6 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -26,7 +25,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: listCmd,
Parent: containerCmd,
})

View File

@ -77,7 +77,6 @@ func init() {
// logs
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: logsCommand,
})
logsFlags(logsCommand)
@ -85,7 +84,6 @@ func init() {
// container logs
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerLogsCommand,
Parent: containerCmd,
})

View File

@ -25,6 +25,11 @@ var (
`
mountCommand = &cobra.Command{
Annotations: map[string]string{
registry.UnshareNSRequired: "",
registry.ParentNSRequired: "",
registry.EngineMode: registry.ABIMode,
},
Use: "mount [options] [CONTAINER...]",
Short: "Mount a working container's root filesystem",
Long: mountDescription,
@ -32,20 +37,16 @@ var (
Args: func(cmd *cobra.Command, args []string) error {
return validate.CheckAllLatestAndCIDFile(cmd, args, true, false)
},
Annotations: map[string]string{
registry.UnshareNSRequired: "",
registry.ParentNSRequired: "",
},
ValidArgsFunction: common.AutocompleteContainers,
}
containerMountCommand = &cobra.Command{
Annotations: mountCommand.Annotations,
Use: mountCommand.Use,
Short: mountCommand.Short,
Long: mountCommand.Long,
RunE: mountCommand.RunE,
Args: mountCommand.Args,
Annotations: mountCommand.Annotations,
ValidArgsFunction: mountCommand.ValidArgsFunction,
}
)
@ -68,14 +69,12 @@ func mountFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: mountCommand,
})
mountFlags(mountCommand)
validate.AddLatestFlag(mountCommand, &mountOpts.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: containerMountCommand,
Parent: containerCmd,
})

View File

@ -48,14 +48,12 @@ func pauseFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: pauseCommand,
})
flags := pauseCommand.Flags()
pauseFlags(flags)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerPauseCommand,
Parent: containerCmd,
})

View File

@ -56,14 +56,12 @@ func portFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: portCommand,
})
portFlags(portCommand.Flags())
validate.AddLatestFlag(portCommand, &portOpts.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerPortCommand,
Parent: containerCmd,
})

View File

@ -35,7 +35,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: pruneCommand,
Parent: containerCmd,
})

View File

@ -60,14 +60,12 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: psCommand,
})
listFlagSet(psCommand)
validate.AddLatestFlag(psCommand, &listOpts.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: psContainerCommand,
Parent: containerCmd,
})

View File

@ -33,12 +33,10 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: renameCommand,
})
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerRenameCommand,
Parent: containerCmd,
})

View File

@ -39,6 +39,7 @@ var (
Short: restartCommand.Short,
Long: restartCommand.Long,
RunE: restartCommand.RunE,
Args: restartCommand.Args,
ValidArgsFunction: restartCommand.ValidArgsFunction,
Example: `podman container restart ctrID
podman container restart --latest
@ -66,14 +67,12 @@ func restartFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: restartCommand,
})
restartFlags(restartCommand)
validate.AddLatestFlag(restartCommand, &restartOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerRestartCommand,
Parent: containerCmd,
})

View File

@ -42,7 +42,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: restoreCommand,
Parent: containerCmd,
})

View File

@ -42,9 +42,7 @@ var (
Short: rmCommand.Short,
Long: rmCommand.Long,
RunE: rmCommand.RunE,
Args: func(cmd *cobra.Command, args []string) error {
return validate.CheckAllLatestAndCIDFile(cmd, args, false, true)
},
Args: rmCommand.Args,
ValidArgsFunction: rmCommand.ValidArgsFunction,
Example: `podman container rm imageID
podman container rm mywebserver myflaskserver 860a4b23
@ -79,14 +77,12 @@ func rmFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: rmCommand,
})
rmFlags(rmCommand)
validate.AddLatestFlag(rmCommand, &rmOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerRmCommand,
Parent: containerCmd,
})

View File

@ -91,14 +91,12 @@ func runFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: runCommand,
})
runFlags(runCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerRunCommand,
Parent: containerCmd,
})

View File

@ -25,6 +25,7 @@ var (
runlabelOptions = runlabelOptionsWrapper{}
runlabelDescription = "Executes a command as described by a container image label."
runlabelCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "runlabel [options] LABEL IMAGE [ARG...]",
Short: "Execute the command described by an image label",
Long: runlabelDescription,
@ -39,7 +40,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: runlabelCommand,
Parent: containerCmd,
})

View File

@ -70,14 +70,12 @@ func startFlags(cmd *cobra.Command) {
}
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: startCommand,
})
startFlags(startCommand)
validate.AddLatestFlag(startCommand, &startOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerStartCommand,
Parent: containerCmd,
})

View File

@ -79,14 +79,12 @@ func statFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: statsCommand,
})
statFlags(statsCommand)
validate.AddLatestFlag(statsCommand, &statsOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerStatsCommand,
Parent: containerCmd,
})

View File

@ -78,14 +78,12 @@ func stopFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: stopCommand,
})
stopFlags(stopCommand)
validate.AddLatestFlag(stopCommand, &stopOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerStopCommand,
Parent: containerCmd,
})

View File

@ -58,7 +58,6 @@ func topFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: topCommand,
})
topFlags(topCommand.Flags())
@ -71,7 +70,6 @@ func init() {
}
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerTopCommand,
Parent: containerCmd,
})

View File

@ -20,6 +20,7 @@ var (
An unmount can be forced with the --force flag.
`
unmountCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "unmount [options] CONTAINER [CONTAINER...]",
Aliases: []string{"umount"},
Short: "Unmounts working container's root filesystem",
@ -35,6 +36,7 @@ var (
}
containerUnmountCommand = &cobra.Command{
Annotations: unmountCommand.Annotations,
Use: unmountCommand.Use,
Short: unmountCommand.Short,
Aliases: unmountCommand.Aliases,
@ -61,14 +63,12 @@ func unmountFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: unmountCommand,
})
unmountFlags(unmountCommand.Flags())
validate.AddLatestFlag(unmountCommand, &unmountOpts.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: containerUnmountCommand,
Parent: containerCmd,
})

View File

@ -45,14 +45,12 @@ func unpauseFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: unpauseCommand,
})
flags := unpauseCommand.Flags()
unpauseFlags(flags)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerUnpauseCommand,
Parent: containerCmd,
})

View File

@ -60,14 +60,12 @@ func waitFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: waitCommand,
})
waitFlags(waitCommand)
validate.AddLatestFlag(waitCommand, &waitOptions.Latest)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: containerWaitCommand,
Parent: containerCmd,
})

View File

@ -34,7 +34,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: diffCmd,
})
flags := diffCmd.Flags()

View File

@ -3,7 +3,6 @@ package pods
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/util"
"github.com/spf13/cobra"
)
@ -21,7 +20,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: generateCmd,
})
}

View File

@ -38,7 +38,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: kubeCmd,
Parent: generateCmd,
})

View File

@ -40,7 +40,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: systemdCmd,
Parent: generateCmd,
})

View File

@ -3,12 +3,10 @@ package healthcheck
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
var (
// Command: healthcheck
healthCmd = &cobra.Command{
Use: "healthcheck",
Short: "Manage health checks on containers",
@ -19,7 +17,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: healthCmd,
})
}

View File

@ -11,23 +11,20 @@ import (
)
var (
healthcheckRunDescription = "run the health check of a container"
healthcheckrunCommand = &cobra.Command{
runCmd = &cobra.Command{
Use: "run CONTAINER",
Short: "run the health check of a container",
Long: healthcheckRunDescription,
Long: "run the health check of a container",
Example: `podman healthcheck run mywebapp`,
RunE: run,
Args: cobra.ExactArgs(1),
ValidArgsFunction: common.AutocompleteContainersRunning,
DisableFlagsInUseLine: true,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: healthcheckrunCommand,
Command: runCmd,
Parent: healthCmd,
})
}

View File

@ -82,14 +82,11 @@ func useLayers() string {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: buildCmd,
})
buildFlags(buildCmd)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageBuildCmd,
Parent: imageCmd,
})

View File

@ -27,7 +27,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: diffCmd,
Parent: imageCmd,
})

View File

@ -3,7 +3,6 @@ package images
import (
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -17,13 +16,11 @@ var (
ValidArgsFunction: common.AutocompleteImages,
Example: `podman image exists ID
podman image exists IMAGE && podman pull IMAGE`,
DisableFlagsInUseLine: true,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: existsCmd,
Parent: imageCmd,
})

View File

@ -56,13 +56,11 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: historyCmd,
})
historyFlags(historyCmd)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageHistoryCmd,
Parent: imageCmd,
})

View File

@ -3,7 +3,6 @@ package images
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -22,7 +21,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageCmd,
})
}

View File

@ -1,32 +0,0 @@
package images
import (
"strings"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
var (
// podman _images_ Alias for podman image _list_
imagesCmd = &cobra.Command{
Use: strings.Replace(listCmd.Use, "list", "images", 1),
Args: listCmd.Args,
Short: listCmd.Short,
Long: listCmd.Long,
RunE: listCmd.RunE,
ValidArgsFunction: listCmd.ValidArgsFunction,
Example: strings.Replace(listCmd.Example, "podman image list", "podman images", -1),
DisableFlagsInUseLine: true,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imagesCmd,
})
imageListFlagSet(imagesCmd)
}

View File

@ -51,13 +51,11 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: importCommand,
})
importFlags(importCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageImportCommand,
Parent: imageCmd,
})

View File

@ -26,7 +26,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: inspectCmd,
Parent: imageCmd,
})

View File

@ -34,8 +34,7 @@ type listFlagType struct {
}
var (
// Command: podman image _list_
listCmd = &cobra.Command{
imageListCmd = &cobra.Command{
Use: "list [options] [IMAGE]",
Aliases: []string{"ls"},
Args: cobra.MaximumNArgs(1),
@ -46,7 +45,18 @@ var (
Example: `podman image list --format json
podman image list --sort repository --format "table {{.ID}} {{.Repository}} {{.Tag}}"
podman image list --filter dangling=true`,
DisableFlagsInUseLine: true,
}
imagesCmd = &cobra.Command{
Use: "images [options] [IMAGE]",
Args: imageListCmd.Args,
Short: imageListCmd.Short,
Long: imageListCmd.Long,
RunE: imageListCmd.RunE,
ValidArgsFunction: imageListCmd.ValidArgsFunction,
Example: `podman images --format json
podman images --sort repository --format "table {{.ID}} {{.Repository}} {{.Tag}}"
podman images --filter dangling=true`,
}
// Options to pull data
@ -65,11 +75,15 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: listCmd,
Command: imageListCmd,
Parent: imageCmd,
})
imageListFlagSet(listCmd)
imageListFlagSet(imageListCmd)
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: imagesCmd,
})
imageListFlagSet(imagesCmd)
}
func imageListFlagSet(cmd *cobra.Command) {

View File

@ -45,12 +45,10 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: loadCommand,
})
loadFlags(loadCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageLoadCommand,
Parent: imageCmd,
})

View File

@ -24,6 +24,11 @@ var (
`
mountCommand = &cobra.Command{
Annotations: map[string]string{
registry.UnshareNSRequired: "",
registry.ParentNSRequired: "",
registry.EngineMode: registry.ABIMode,
},
Use: "mount [options] [IMAGE...]",
Short: "Mount an image's root filesystem",
Long: mountDescription,
@ -33,10 +38,6 @@ var (
podman image mount imgID1 imgID2 imgID3
podman image mount
podman image mount --all`,
Annotations: map[string]string{
registry.UnshareNSRequired: "",
registry.ParentNSRequired: "",
},
}
)
@ -56,7 +57,6 @@ func mountFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: mountCommand,
Parent: imageCmd,
})

View File

@ -34,7 +34,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: pruneCmd,
Parent: imageCmd,
})

View File

@ -60,14 +60,12 @@ var (
func init() {
// pull
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: pullCmd,
})
pullFlags(pullCmd)
// images pull
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imagesPullCmd,
Parent: imageCmd,
})

View File

@ -57,14 +57,12 @@ var (
func init() {
// push
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: pushCmd,
})
pushFlags(pushCmd)
// images push
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imagePushCmd,
Parent: imageCmd,
})

View File

@ -25,17 +25,33 @@ var (
podman image rm c4dfb1609ee2 93fd78260bd1 c0ed59d05ff7`,
}
rmiCmd = &cobra.Command{
Use: "rmi [options] IMAGE [IMAGE...]",
Args: rmCmd.Args,
Short: rmCmd.Short,
Long: rmCmd.Long,
RunE: rmCmd.RunE,
ValidArgsFunction: rmCmd.ValidArgsFunction,
Example: `podman rmi imageID
podman rmi --force alpine
podman rmi c4dfb1609ee2 93fd78260bd1 c0ed59d05ff7`,
}
imageOpts = entities.ImageRemoveOptions{}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: rmCmd,
Parent: imageCmd,
})
imageRemoveFlagSet(rmCmd.Flags())
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: rmiCmd,
})
imageRemoveFlagSet(rmiCmd.Flags())
}
func imageRemoveFlagSet(flags *pflag.FlagSet) {

View File

@ -1,29 +0,0 @@
package images
import (
"strings"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
var (
rmiCmd = &cobra.Command{
Use: strings.Replace(rmCmd.Use, "rm ", "rmi ", 1),
Args: rmCmd.Args,
Short: rmCmd.Short,
Long: rmCmd.Long,
RunE: rmCmd.RunE,
ValidArgsFunction: rmCmd.ValidArgsFunction,
Example: strings.Replace(rmCmd.Example, "podman image rm", "podman rmi", -1),
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: rmiCmd,
})
imageRemoveFlagSet(rmiCmd.Flags())
}

View File

@ -48,6 +48,7 @@ var (
podman save --format docker-dir -o ubuntu-dir ubuntu
podman save > alpine-all.tar alpine:latest`,
}
imageSaveCommand = &cobra.Command{
Args: saveCommand.Args,
Use: saveCommand.Use,
@ -67,13 +68,11 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: saveCommand,
})
saveFlags(saveCommand)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageSaveCommand,
Parent: imageCmd,
})

View File

@ -38,7 +38,6 @@ var (
Users can limit the number of results, and filter the output based on certain conditions.`
// Command: podman search
searchCmd = &cobra.Command{
Use: "search [options] TERM",
Short: "Search registry for image",
@ -51,14 +50,12 @@ var (
podman search --format "table {{.Index}} {{.Name}}" registry.fedoraproject.org/fedora`,
}
// Command: podman image search
imageSearchCmd = &cobra.Command{
Use: searchCmd.Use,
Short: searchCmd.Short,
Long: searchCmd.Long,
RunE: searchCmd.RunE,
Args: searchCmd.Args,
Annotations: searchCmd.Annotations,
ValidArgsFunction: searchCmd.ValidArgsFunction,
Example: `podman image search --filter=is-official --limit 3 alpine
podman image search registry.fedoraproject.org/ # only works with v2 registries
@ -67,16 +64,12 @@ var (
)
func init() {
// search
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: searchCmd,
})
searchFlags(searchCmd)
// images search
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageSearchCmd,
Parent: imageCmd,
})

View File

@ -14,6 +14,7 @@ import (
var (
signDescription = "Create a signature file that can be used later to verify the image."
signCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "sign [options] IMAGE [IMAGE...]",
Short: "Sign an image",
Long: signDescription,
@ -31,7 +32,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: signCommand,
Parent: imageCmd,
})

View File

@ -15,7 +15,6 @@ var (
Long: tagDescription,
RunE: tag,
Args: cobra.MinimumNArgs(2),
DisableFlagsInUseLine: true,
ValidArgsFunction: common.AutocompleteImages,
Example: `podman tag 0e3bbc2 fedora:latest
podman tag imageID:latest myNewImage:newTag
@ -24,7 +23,6 @@ var (
imageTagCommand = &cobra.Command{
Args: tagCommand.Args,
DisableFlagsInUseLine: true,
Use: tagCommand.Use,
Short: tagCommand.Short,
Long: tagCommand.Long,
@ -38,11 +36,9 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: tagCommand,
})
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageTagCommand,
Parent: imageCmd,
})

View File

@ -25,7 +25,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: treeCmd,
Parent: imageCmd,
})

View File

@ -3,7 +3,6 @@ package images
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -11,6 +10,7 @@ var (
trustDescription = `Manages which registries you trust as a source of container images based on their location.
The location is determined by the transport and the registry host of the image. Using this container image docker://quay.io/podman/stable as an example, docker is the transport and quay.io is the registry host.`
trustCmd = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "trust",
Short: "Manage container image trust policy",
Long: trustDescription,
@ -20,7 +20,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: trustCmd,
Parent: imageCmd,
})

View File

@ -16,6 +16,7 @@ import (
var (
setTrustDescription = "Set default trust policy or add a new trust policy for a registry"
setTrustCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "set [options] REGISTRY",
Short: "Set default trust policy or a new trust policy for a registry",
Long: setTrustDescription,
@ -32,7 +33,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: setTrustCommand,
Parent: trustCmd,
})

View File

@ -15,6 +15,7 @@ import (
var (
showTrustDescription = "Display trust policy for the system"
showTrustCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "show [options] [REGISTRY]",
Short: "Display trust policy for the system",
Long: showTrustDescription,
@ -31,7 +32,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: showTrustCommand,
Parent: trustCmd,
})

View File

@ -20,6 +20,7 @@ var (
An unmount can be forced with the --force flag.
`
unmountCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "unmount [options] IMAGE [IMAGE...]",
Aliases: []string{"umount"},
Short: "Unmount an image's root filesystem",
@ -43,7 +44,6 @@ func unmountFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Parent: imageCmd,
Command: unmountCommand,
})

View File

@ -8,27 +8,25 @@ import (
)
var (
untagCommand = &cobra.Command{
untagCmd = &cobra.Command{
Use: "untag IMAGE [IMAGE...]",
Short: "Remove a name from a local image",
Long: "Removes one or more names from a locally-stored image.",
RunE: untag,
Args: cobra.MinimumNArgs(1),
DisableFlagsInUseLine: true,
ValidArgsFunction: common.AutocompleteImages,
Example: `podman untag 0e3bbc2
podman untag imageID:latest otherImageName:latest
podman untag httpd myregistryhost:5000/fedora/httpd:v2`,
}
imageUntagCommand = &cobra.Command{
Args: untagCommand.Args,
DisableFlagsInUseLine: true,
Use: untagCommand.Use,
Short: untagCommand.Short,
Long: untagCommand.Long,
RunE: untagCommand.RunE,
ValidArgsFunction: untagCommand.ValidArgsFunction,
imageUntagCmd = &cobra.Command{
Args: untagCmd.Args,
Use: untagCmd.Use,
Short: untagCmd.Short,
Long: untagCmd.Long,
RunE: untagCmd.RunE,
ValidArgsFunction: untagCmd.ValidArgsFunction,
Example: `podman image untag 0e3bbc2
podman image untag imageID:latest otherImageName:latest
podman image untag httpd myregistryhost:5000/fedora/httpd:v2`,
@ -37,12 +35,10 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: untagCommand,
Command: untagCmd,
})
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: imageUntagCommand,
Command: imageUntagCmd,
Parent: imageCmd,
})
}

View File

@ -36,7 +36,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: inspectCmd,
})
inspectOpts = inspect.AddInspectFlagSet(inspectCmd)

View File

@ -9,7 +9,6 @@ import (
"github.com/containers/image/v5/types"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/registries"
"github.com/spf13/cobra"
)
@ -39,7 +38,6 @@ func init() {
// store credentials locally while the remote client will pass them
// over the wire to the endpoint.
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: loginCommand,
})
flags := loginCommand.Flags()

View File

@ -8,7 +8,6 @@ import (
"github.com/containers/image/v5/types"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/registries"
"github.com/spf13/cobra"
)
@ -33,7 +32,6 @@ func init() {
// store credentials locally while the remote client will pass them
// over the wire to the endpoint.
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: logoutCommand,
})
flags := logoutCommand.Flags()

View File

@ -5,7 +5,6 @@ package machine
import (
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
"github.com/pkg/errors"
@ -26,12 +25,11 @@ var (
var (
initOpts = machine.InitOptions{}
defaultMachineName string = "podman-machine-default"
defaultMachineName = "podman-machine-default"
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: initCmd,
Parent: machineCmd,
})

View File

@ -15,7 +15,6 @@ import (
"github.com/containers/podman/v3/cmd/podman/parse"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
"github.com/docker/go-units"
@ -31,9 +30,9 @@ var (
Long: "List managed virtual machines.",
RunE: list,
Args: validate.NoArgs,
ValidArgsFunction: completion.AutocompleteNone,
Example: `podman machine list,
podman machine ls`,
ValidArgsFunction: completion.AutocompleteNone,
}
listFlag = listFlagType{}
)
@ -52,7 +51,6 @@ type machineReporter struct {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: lsCmd,
Parent: machineCmd,
})

View File

@ -7,7 +7,6 @@ import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
"github.com/spf13/cobra"
@ -30,7 +29,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: machineCmd,
})
}

View File

@ -2,4 +2,5 @@
package machine
// init do not register _podman machine_ command on unsupported platforms
func init() {}

View File

@ -9,7 +9,6 @@ import (
"strings"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
"github.com/spf13/cobra"
@ -33,7 +32,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: rmCmd,
Parent: machineCmd,
})

View File

@ -4,7 +4,6 @@ package machine
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
"github.com/pkg/errors"
@ -30,7 +29,6 @@ var (
func init() {
sshCmd.Flags().SetInterspersed(false)
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: sshCmd,
Parent: machineCmd,
})

View File

@ -4,7 +4,6 @@ package machine
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
"github.com/pkg/errors"
@ -25,7 +24,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: startCmd,
Parent: machineCmd,
})

View File

@ -4,7 +4,6 @@ package machine
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
"github.com/spf13/cobra"
@ -24,7 +23,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: stopCmd,
Parent: machineCmd,
})

View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"strings"
_ "github.com/containers/podman/v3/cmd/podman/completion"
_ "github.com/containers/podman/v3/cmd/podman/containers"
@ -42,12 +43,16 @@ func main() {
func parseCommands() *cobra.Command {
cfg := registry.PodmanConfig()
for _, c := range registry.Commands {
for _, m := range c.Mode {
if cfg.EngineMode == m {
if supported, found := c.Command.Annotations[registry.EngineMode]; found {
if !strings.Contains(cfg.EngineMode.String(), supported) {
continue
}
}
// Command cannot be run rootless
_, found := c.Command.Annotations[registry.UnshareNSRequired]
if found {
if rootless.IsRootless() && found && os.Getuid() != 0 {
if rootless.IsRootless() && os.Getuid() != 0 {
c.Command.RunE = func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("cannot run command %q in rootless mode, must execute `podman unshare` first", cmd.CommandPath())
}
@ -60,6 +65,7 @@ func parseCommands() *cobra.Command {
}
}
}
parent := rootCmd
if c.Parent != nil {
parent = c.Parent
@ -73,8 +79,6 @@ func parseCommands() *cobra.Command {
c.Command.SetUsageTemplate(usageTemplate)
c.Command.DisableFlagsInUseLine = true
}
}
}
if err := terminal.SetConsole(); err != nil {
logrus.Error(err)
os.Exit(1)

View File

@ -39,7 +39,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: addCmd,
Parent: manifestCmd,
})

View File

@ -15,6 +15,7 @@ import (
var (
manifestAnnotateOpts = entities.ManifestAnnotateOptions{}
annotateCmd = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "annotate [options] LIST IMAGE",
Short: "Add or update information about an entry in a manifest list or image index",
Long: "Adds or updates information about an entry in a manifest list or image index.",
@ -27,7 +28,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: annotateCmd,
Parent: manifestCmd,
})

View File

@ -27,7 +27,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: createCmd,
Parent: manifestCmd,
})

View File

@ -3,7 +3,6 @@ package manifest
import (
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -21,7 +20,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: existsCmd,
Parent: manifestCmd,
})

View File

@ -6,7 +6,6 @@ import (
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -19,13 +18,11 @@ var (
ValidArgsFunction: common.AutocompleteImages,
Example: "podman manifest inspect localhost/list",
Args: cobra.ExactArgs(1),
DisableFlagsInUseLine: true,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: inspectCmd,
Parent: manifestCmd,
})

View File

@ -3,7 +3,6 @@ package manifest
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -26,7 +25,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: manifestCmd,
})
}

View File

@ -39,7 +39,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: pushCmd,
Parent: manifestCmd,
})

View File

@ -6,7 +6,6 @@ import (
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -20,13 +19,11 @@ var (
ValidArgsFunction: common.AutocompleteImages,
Example: `podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`,
Args: cobra.ExactArgs(2),
DisableFlagsInUseLine: true,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: removeCmd,
Parent: manifestCmd,
})

View File

@ -6,7 +6,6 @@ import (
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/errorhandling"
"github.com/spf13/cobra"
)
@ -20,13 +19,11 @@ var (
ValidArgsFunction: common.AutocompleteImages,
Example: `podman manifest rm mylist:v1.11`,
Args: cobra.ExactArgs(1),
DisableFlagsInUseLine: true,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: rmCmd,
Parent: manifestCmd,
})

View File

@ -34,7 +34,6 @@ func networkConnectFlags(cmd *cobra.Command) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkConnectCommand,
Parent: networkCmd,
})

View File

@ -75,7 +75,6 @@ func networkCreateFlags(cmd *cobra.Command) {
}
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkCreateCommand,
Parent: networkCmd,
})

View File

@ -31,7 +31,6 @@ func networkDisconnectFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkDisconnectCommand,
Parent: networkCmd,
})

View File

@ -3,7 +3,6 @@ package network
import (
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -22,7 +21,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkExistsCommand,
Parent: networkCmd,
})

View File

@ -24,7 +24,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkinspectCommand,
Parent: networkCmd,
})

View File

@ -54,7 +54,6 @@ func networkListFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networklistCommand,
Parent: networkCmd,
})

View File

@ -3,7 +3,6 @@ package network
import (
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/spf13/cobra"
)
@ -22,7 +21,6 @@ var (
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkCmd,
})
}

View File

@ -43,7 +43,6 @@ func networkPruneFlags(cmd *cobra.Command, flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkPruneCommand,
Parent: networkCmd,
})

View File

@ -15,6 +15,7 @@ import (
var (
networkReloadDescription = `reload container networks, recreating firewall rules`
networkReloadCommand = &cobra.Command{
Annotations: map[string]string{registry.EngineMode: registry.ABIMode},
Use: "reload [options] [CONTAINER...]",
Short: "Reload firewall rules for one or more containers",
Long: networkReloadDescription,
@ -39,7 +40,6 @@ func reloadFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: networkReloadCommand,
Parent: networkCmd,
})

View File

@ -38,7 +38,6 @@ func networkRmFlags(flags *pflag.FlagSet) {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: networkrmCommand,
Parent: networkCmd,
})

Some files were not shown because too many files have changed in this diff Show More