From 33944cefe7c1f3e11c8389bedb3e4c80af8541bd Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Tue, 18 May 2021 11:23:25 -0700 Subject: [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 --- cmd/podman/README.md | 6 ---- cmd/podman/auto-update.go | 2 +- cmd/podman/completion/completion.go | 2 -- cmd/podman/containers/attach.go | 2 -- cmd/podman/containers/checkpoint.go | 1 - cmd/podman/containers/cleanup.go | 10 +++--- cmd/podman/containers/commit.go | 2 -- cmd/podman/containers/container.go | 2 -- cmd/podman/containers/cp.go | 2 -- cmd/podman/containers/create.go | 4 +-- cmd/podman/containers/diff.go | 1 - cmd/podman/containers/exec.go | 24 ++++++------- cmd/podman/containers/exists.go | 8 ++--- cmd/podman/containers/export.go | 2 -- cmd/podman/containers/init.go | 2 -- cmd/podman/containers/inspect.go | 1 - cmd/podman/containers/kill.go | 2 -- cmd/podman/containers/list.go | 2 -- cmd/podman/containers/logs.go | 2 -- cmd/podman/containers/mount.go | 13 ++++--- cmd/podman/containers/pause.go | 2 -- cmd/podman/containers/port.go | 2 -- cmd/podman/containers/prune.go | 1 - cmd/podman/containers/ps.go | 2 -- cmd/podman/containers/rename.go | 2 -- cmd/podman/containers/restart.go | 3 +- cmd/podman/containers/restore.go | 1 - cmd/podman/containers/rm.go | 14 +++----- cmd/podman/containers/run.go | 2 -- cmd/podman/containers/runlabel.go | 2 +- cmd/podman/containers/start.go | 2 -- cmd/podman/containers/stats.go | 2 -- cmd/podman/containers/stop.go | 2 -- cmd/podman/containers/top.go | 2 -- cmd/podman/containers/unmount.go | 24 ++++++------- cmd/podman/containers/unpause.go | 2 -- cmd/podman/containers/wait.go | 2 -- cmd/podman/diff.go | 1 - cmd/podman/generate/generate.go | 2 -- cmd/podman/generate/kube.go | 1 - cmd/podman/generate/systemd.go | 1 - cmd/podman/healthcheck/healthcheck.go | 3 -- cmd/podman/healthcheck/run.go | 21 +++++------ cmd/podman/images/build.go | 3 -- cmd/podman/images/diff.go | 1 - cmd/podman/images/exists.go | 3 -- cmd/podman/images/history.go | 2 -- cmd/podman/images/image.go | 2 -- cmd/podman/images/images.go | 32 ----------------- cmd/podman/images/import.go | 2 -- cmd/podman/images/inspect.go | 1 - cmd/podman/images/list.go | 26 ++++++++++---- cmd/podman/images/load.go | 2 -- cmd/podman/images/mount.go | 10 +++--- cmd/podman/images/prune.go | 1 - cmd/podman/images/pull.go | 2 -- cmd/podman/images/push.go | 2 -- cmd/podman/images/rm.go | 18 +++++++++- cmd/podman/images/rmi.go | 29 --------------- cmd/podman/images/save.go | 3 +- cmd/podman/images/search.go | 7 ---- cmd/podman/images/sign.go | 2 +- cmd/podman/images/tag.go | 28 +++++++-------- cmd/podman/images/tree.go | 1 - cmd/podman/images/trust.go | 11 +++--- cmd/podman/images/trust_set.go | 2 +- cmd/podman/images/trust_show.go | 2 +- cmd/podman/images/unmount.go | 2 +- cmd/podman/images/untag.go | 36 +++++++++---------- cmd/podman/inspect.go | 1 - cmd/podman/login.go | 2 -- cmd/podman/logout.go | 2 -- cmd/podman/machine/init.go | 6 ++-- cmd/podman/machine/list.go | 16 ++++----- cmd/podman/machine/machine.go | 2 -- cmd/podman/machine/machine_unsupported.go | 1 + cmd/podman/machine/rm.go | 2 -- cmd/podman/machine/ssh.go | 2 -- cmd/podman/machine/start.go | 2 -- cmd/podman/machine/stop.go | 2 -- cmd/podman/main.go | 60 ++++++++++++++++--------------- cmd/podman/manifest/add.go | 1 - cmd/podman/manifest/annotate.go | 2 +- cmd/podman/manifest/create.go | 1 - cmd/podman/manifest/exists.go | 2 -- cmd/podman/manifest/inspect.go | 17 ++++----- cmd/podman/manifest/manifest.go | 2 -- cmd/podman/manifest/push.go | 1 - cmd/podman/manifest/remove.go | 17 ++++----- cmd/podman/manifest/rm.go | 17 ++++----- cmd/podman/networks/connect.go | 1 - cmd/podman/networks/create.go | 1 - cmd/podman/networks/disconnect.go | 1 - cmd/podman/networks/exists.go | 2 -- cmd/podman/networks/inspect.go | 1 - cmd/podman/networks/list.go | 1 - cmd/podman/networks/network.go | 2 -- cmd/podman/networks/prune.go | 1 - cmd/podman/networks/reload.go | 10 +++--- cmd/podman/networks/rm.go | 1 - cmd/podman/play/kube.go | 1 - cmd/podman/play/play.go | 2 -- cmd/podman/pods/create.go | 1 - cmd/podman/pods/exists.go | 3 -- cmd/podman/pods/inspect.go | 1 - cmd/podman/pods/kill.go | 1 - cmd/podman/pods/pause.go | 1 - cmd/podman/pods/pod.go | 2 -- cmd/podman/pods/prune.go | 1 - cmd/podman/pods/ps.go | 1 - cmd/podman/pods/restart.go | 1 - cmd/podman/pods/rm.go | 1 - cmd/podman/pods/start.go | 1 - cmd/podman/pods/stats.go | 1 - cmd/podman/pods/stop.go | 1 - cmd/podman/pods/top.go | 1 - cmd/podman/pods/unpause.go | 1 - cmd/podman/registry/config.go | 13 ++++++- cmd/podman/registry/registry.go | 1 - cmd/podman/secrets/create.go | 1 - cmd/podman/secrets/inspect.go | 1 - cmd/podman/secrets/list.go | 1 - cmd/podman/secrets/rm.go | 1 - cmd/podman/secrets/secret.go | 2 -- cmd/podman/system/connection.go | 17 ++++----- cmd/podman/system/connection/add.go | 2 -- cmd/podman/system/connection/default.go | 17 ++++----- cmd/podman/system/connection/list.go | 13 +++---- cmd/podman/system/connection/remove.go | 17 ++++----- cmd/podman/system/connection/rename.go | 17 ++++----- cmd/podman/system/df.go | 1 - cmd/podman/system/events.go | 1 - cmd/podman/system/info.go | 3 -- cmd/podman/system/migrate.go | 2 +- cmd/podman/system/prune.go | 1 - cmd/podman/system/renumber.go | 15 ++++---- cmd/podman/system/reset.go | 2 +- cmd/podman/system/service.go | 2 +- cmd/podman/system/system.go | 2 -- cmd/podman/system/unshare.go | 13 ++++--- cmd/podman/system/version.go | 1 - cmd/podman/volumes/create.go | 1 - cmd/podman/volumes/exists.go | 2 -- cmd/podman/volumes/inspect.go | 1 - cmd/podman/volumes/list.go | 1 - cmd/podman/volumes/prune.go | 1 - cmd/podman/volumes/rm.go | 1 - cmd/podman/volumes/volume.go | 2 -- 148 files changed, 264 insertions(+), 507 deletions(-) delete mode 100644 cmd/podman/images/images.go delete mode 100644 cmd/podman/images/rmi.go diff --git a/cmd/podman/README.md b/cmd/podman/README.md index 260c9bcfc..f2aa3f018 100644 --- a/cmd/podman/README.md +++ b/cmd/podman/README.md @@ -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, diff --git a/cmd/podman/auto-update.go b/cmd/podman/auto-update.go index a6d990b0c..99226790f 100644 --- a/cmd/podman/auto-update.go +++ b/cmd/podman/auto-update.go @@ -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, }) diff --git a/cmd/podman/completion/completion.go b/cmd/podman/completion/completion.go index 472068130..da74eefdd 100644 --- a/cmd/podman/completion/completion.go +++ b/cmd/podman/completion/completion.go @@ -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() diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go index dae1126a9..acfa0357b 100644 --- a/cmd/podman/containers/attach.go +++ b/cmd/podman/containers/attach.go @@ -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, }) diff --git a/cmd/podman/containers/checkpoint.go b/cmd/podman/containers/checkpoint.go index 25d0eb510..47d60453b 100644 --- a/cmd/podman/containers/checkpoint.go +++ b/cmd/podman/containers/checkpoint.go @@ -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, }) diff --git a/cmd/podman/containers/cleanup.go b/cmd/podman/containers/cleanup.go index 1f87725e9..98706c575 100644 --- a/cmd/podman/containers/cleanup.go +++ b/cmd/podman/containers/cleanup.go @@ -21,10 +21,11 @@ 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{ - Use: "cleanup [options] CONTAINER [CONTAINER...]", - Short: "Cleanup network and mountpoints of one or more containers", - Long: cleanupDescription, - RunE: cleanup, + 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, + RunE: cleanup, Args: func(cmd *cobra.Command, args []string) error { return validate.CheckAllLatestAndCIDFile(cmd, args, false, false) }, @@ -41,7 +42,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode}, Parent: containerCmd, Command: cleanupCommand, }) diff --git a/cmd/podman/containers/commit.go b/cmd/podman/containers/commit.go index 168ded356..f74f12851 100644 --- a/cmd/podman/containers/commit.go +++ b/cmd/podman/containers/commit.go @@ -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, }) diff --git a/cmd/podman/containers/container.go b/cmd/podman/containers/container.go index c78668611..14e030bf4 100644 --- a/cmd/podman/containers/container.go +++ b/cmd/podman/containers/container.go @@ -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, }) } diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go index 27aacc6e5..2c7d72b20 100644 --- a/cmd/podman/containers/cp.go +++ b/cmd/podman/containers/cp.go @@ -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, }) diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index f06869c4e..07a859983 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -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, }) diff --git a/cmd/podman/containers/diff.go b/cmd/podman/containers/diff.go index 799d01127..0eee85825 100644 --- a/cmd/podman/containers/diff.go +++ b/cmd/podman/containers/diff.go @@ -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, }) diff --git a/cmd/podman/containers/exec.go b/cmd/podman/containers/exec.go index 15ac2b164..5d0da1514 100644 --- a/cmd/podman/containers/exec.go +++ b/cmd/podman/containers/exec.go @@ -21,24 +21,22 @@ var ( execDescription = `Execute the specified command inside a running container. ` execCommand = &cobra.Command{ - Use: "exec [options] CONTAINER [COMMAND [ARG...]]", - Short: "Run a process in a running container", - Long: execDescription, - RunE: exec, - DisableFlagsInUseLine: true, - ValidArgsFunction: common.AutocompleteExecCommand, + Use: "exec [options] CONTAINER [COMMAND [ARG...]]", + Short: "Run a process in a running container", + Long: execDescription, + RunE: exec, + ValidArgsFunction: common.AutocompleteExecCommand, Example: `podman exec -it ctrID ls podman exec -it -w /tmp myCtr pwd podman exec --user root ctrID ls`, } containerExecCommand = &cobra.Command{ - Use: execCommand.Use, - Short: execCommand.Short, - Long: execCommand.Long, - RunE: execCommand.RunE, - DisableFlagsInUseLine: true, - ValidArgsFunction: execCommand.ValidArgsFunction, + Use: execCommand.Use, + Short: execCommand.Short, + Long: execCommand.Long, + RunE: execCommand.RunE, + ValidArgsFunction: execCommand.ValidArgsFunction, Example: `podman container exec -it ctrID ls podman container exec -it -w /tmp myCtr pwd podman container exec --user root ctrID ls`, @@ -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, }) diff --git a/cmd/podman/containers/exists.go b/cmd/podman/containers/exists.go index c21b30a4b..cf7ac4c5d 100644 --- a/cmd/podman/containers/exists.go +++ b/cmd/podman/containers/exists.go @@ -18,16 +18,14 @@ var ( Long: containerExistsDescription, Example: `podman container exists --external containerID podman container exists myctr || podman run --name myctr [etc...]`, - RunE: exists, - Args: cobra.ExactArgs(1), - DisableFlagsInUseLine: true, - ValidArgsFunction: common.AutocompleteContainers, + RunE: exists, + Args: cobra.ExactArgs(1), + ValidArgsFunction: common.AutocompleteContainers, } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: existsCommand, Parent: containerCmd, }) diff --git a/cmd/podman/containers/export.go b/cmd/podman/containers/export.go index 3ea55415c..e031578b8 100644 --- a/cmd/podman/containers/export.go +++ b/cmd/podman/containers/export.go @@ -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, }) diff --git a/cmd/podman/containers/init.go b/cmd/podman/containers/init.go index e874b9cb0..e68217478 100644 --- a/cmd/podman/containers/init.go +++ b/cmd/podman/containers/init.go @@ -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, }) diff --git a/cmd/podman/containers/inspect.go b/cmd/podman/containers/inspect.go index eb29b7285..5a8ccc628 100644 --- a/cmd/podman/containers/inspect.go +++ b/cmd/podman/containers/inspect.go @@ -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, }) diff --git a/cmd/podman/containers/kill.go b/cmd/podman/containers/kill.go index aa36b51fd..449484449 100644 --- a/cmd/podman/containers/kill.go +++ b/cmd/podman/containers/kill.go @@ -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, }) diff --git a/cmd/podman/containers/list.go b/cmd/podman/containers/list.go index 4a903f5ea..203f9560e 100644 --- a/cmd/podman/containers/list.go +++ b/cmd/podman/containers/list.go @@ -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, }) diff --git a/cmd/podman/containers/logs.go b/cmd/podman/containers/logs.go index 6275106cf..0d745291e 100644 --- a/cmd/podman/containers/logs.go +++ b/cmd/podman/containers/logs.go @@ -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, }) diff --git a/cmd/podman/containers/mount.go b/cmd/podman/containers/mount.go index fd5a279d2..8a7c542ba 100644 --- a/cmd/podman/containers/mount.go +++ b/cmd/podman/containers/mount.go @@ -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, }) diff --git a/cmd/podman/containers/pause.go b/cmd/podman/containers/pause.go index a1ac00bfb..8e1b69d71 100644 --- a/cmd/podman/containers/pause.go +++ b/cmd/podman/containers/pause.go @@ -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, }) diff --git a/cmd/podman/containers/port.go b/cmd/podman/containers/port.go index 7c9565c26..db66fc9a0 100644 --- a/cmd/podman/containers/port.go +++ b/cmd/podman/containers/port.go @@ -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, }) diff --git a/cmd/podman/containers/prune.go b/cmd/podman/containers/prune.go index 94da029b9..e55bd8a53 100644 --- a/cmd/podman/containers/prune.go +++ b/cmd/podman/containers/prune.go @@ -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, }) diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 3c0162676..352f67f4e 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -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, }) diff --git a/cmd/podman/containers/rename.go b/cmd/podman/containers/rename.go index 0f4a1dde1..1371e50e0 100644 --- a/cmd/podman/containers/rename.go +++ b/cmd/podman/containers/rename.go @@ -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, }) diff --git a/cmd/podman/containers/restart.go b/cmd/podman/containers/restart.go index 80ffff700..41b33258f 100644 --- a/cmd/podman/containers/restart.go +++ b/cmd/podman/containers/restart.go @@ -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, }) diff --git a/cmd/podman/containers/restore.go b/cmd/podman/containers/restore.go index ad530e308..3b1848abb 100644 --- a/cmd/podman/containers/restore.go +++ b/cmd/podman/containers/restore.go @@ -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, }) diff --git a/cmd/podman/containers/rm.go b/cmd/podman/containers/rm.go index 5822fc4b7..abab71a79 100644 --- a/cmd/podman/containers/rm.go +++ b/cmd/podman/containers/rm.go @@ -38,13 +38,11 @@ var ( } containerRmCommand = &cobra.Command{ - Use: rmCommand.Use, - Short: rmCommand.Short, - Long: rmCommand.Long, - RunE: rmCommand.RunE, - Args: func(cmd *cobra.Command, args []string) error { - return validate.CheckAllLatestAndCIDFile(cmd, args, false, true) - }, + Use: rmCommand.Use, + Short: rmCommand.Short, + Long: rmCommand.Long, + RunE: rmCommand.RunE, + 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, }) diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 4bd06a47b..2611c5b6e 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -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, }) diff --git a/cmd/podman/containers/runlabel.go b/cmd/podman/containers/runlabel.go index 75c2557f0..85f3785be 100644 --- a/cmd/podman/containers/runlabel.go +++ b/cmd/podman/containers/runlabel.go @@ -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, }) diff --git a/cmd/podman/containers/start.go b/cmd/podman/containers/start.go index dcd1eca82..1163b9093 100644 --- a/cmd/podman/containers/start.go +++ b/cmd/podman/containers/start.go @@ -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, }) diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go index 7160f1ba8..568e410d2 100644 --- a/cmd/podman/containers/stats.go +++ b/cmd/podman/containers/stats.go @@ -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, }) diff --git a/cmd/podman/containers/stop.go b/cmd/podman/containers/stop.go index 62ce9b036..13da59a8c 100644 --- a/cmd/podman/containers/stop.go +++ b/cmd/podman/containers/stop.go @@ -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, }) diff --git a/cmd/podman/containers/top.go b/cmd/podman/containers/top.go index 03cee5d56..3fde2e954 100644 --- a/cmd/podman/containers/top.go +++ b/cmd/podman/containers/top.go @@ -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, }) diff --git a/cmd/podman/containers/unmount.go b/cmd/podman/containers/unmount.go index 98bbce581..96470da78 100644 --- a/cmd/podman/containers/unmount.go +++ b/cmd/podman/containers/unmount.go @@ -20,11 +20,12 @@ var ( An unmount can be forced with the --force flag. ` unmountCommand = &cobra.Command{ - Use: "unmount [options] CONTAINER [CONTAINER...]", - Aliases: []string{"umount"}, - Short: "Unmounts working container's root filesystem", - Long: description, - RunE: unmount, + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, + Use: "unmount [options] CONTAINER [CONTAINER...]", + Aliases: []string{"umount"}, + Short: "Unmounts working container's root filesystem", + Long: description, + RunE: unmount, Args: func(cmd *cobra.Command, args []string) error { return validate.CheckAllLatestAndCIDFile(cmd, args, false, false) }, @@ -35,11 +36,12 @@ var ( } containerUnmountCommand = &cobra.Command{ - Use: unmountCommand.Use, - Short: unmountCommand.Short, - Aliases: unmountCommand.Aliases, - Long: unmountCommand.Long, - RunE: unmountCommand.RunE, + Annotations: unmountCommand.Annotations, + Use: unmountCommand.Use, + Short: unmountCommand.Short, + Aliases: unmountCommand.Aliases, + Long: unmountCommand.Long, + RunE: unmountCommand.RunE, Args: func(cmd *cobra.Command, args []string) error { return validate.CheckAllLatestAndCIDFile(cmd, args, false, false) }, @@ -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, }) diff --git a/cmd/podman/containers/unpause.go b/cmd/podman/containers/unpause.go index 0077181d7..e152f70e1 100644 --- a/cmd/podman/containers/unpause.go +++ b/cmd/podman/containers/unpause.go @@ -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, }) diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go index c01bc08b1..e720421a6 100644 --- a/cmd/podman/containers/wait.go +++ b/cmd/podman/containers/wait.go @@ -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, }) diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go index ae7d6c4bc..e2a3cd727 100644 --- a/cmd/podman/diff.go +++ b/cmd/podman/diff.go @@ -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() diff --git a/cmd/podman/generate/generate.go b/cmd/podman/generate/generate.go index a6d39bbbe..6b48a342e 100644 --- a/cmd/podman/generate/generate.go +++ b/cmd/podman/generate/generate.go @@ -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, }) } diff --git a/cmd/podman/generate/kube.go b/cmd/podman/generate/kube.go index 9767b0e06..b4c9f9146 100644 --- a/cmd/podman/generate/kube.go +++ b/cmd/podman/generate/kube.go @@ -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, }) diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go index 8a8f5016a..5461f1f6a 100644 --- a/cmd/podman/generate/systemd.go +++ b/cmd/podman/generate/systemd.go @@ -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, }) diff --git a/cmd/podman/healthcheck/healthcheck.go b/cmd/podman/healthcheck/healthcheck.go index 4a986e171..b42ae2182 100644 --- a/cmd/podman/healthcheck/healthcheck.go +++ b/cmd/podman/healthcheck/healthcheck.go @@ -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, }) } diff --git a/cmd/podman/healthcheck/run.go b/cmd/podman/healthcheck/run.go index 50a51d172..fe8dc2573 100644 --- a/cmd/podman/healthcheck/run.go +++ b/cmd/podman/healthcheck/run.go @@ -11,23 +11,20 @@ import ( ) var ( - healthcheckRunDescription = "run the health check of a container" - healthcheckrunCommand = &cobra.Command{ - Use: "run CONTAINER", - Short: "run the health check of a container", - Long: healthcheckRunDescription, - Example: `podman healthcheck run mywebapp`, - RunE: run, - Args: cobra.ExactArgs(1), - ValidArgsFunction: common.AutocompleteContainersRunning, - DisableFlagsInUseLine: true, + runCmd = &cobra.Command{ + Use: "run CONTAINER", + Short: "run the health check of a container", + Long: "run the health check of a container", + Example: `podman healthcheck run mywebapp`, + RunE: run, + Args: cobra.ExactArgs(1), + ValidArgsFunction: common.AutocompleteContainersRunning, } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, - Command: healthcheckrunCommand, + Command: runCmd, Parent: healthCmd, }) } diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 04fdeab0a..dfb7415a9 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -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, }) diff --git a/cmd/podman/images/diff.go b/cmd/podman/images/diff.go index 7f4c3e83d..2e883d7ae 100644 --- a/cmd/podman/images/diff.go +++ b/cmd/podman/images/diff.go @@ -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, }) diff --git a/cmd/podman/images/exists.go b/cmd/podman/images/exists.go index 332510b3d..d278eafda 100644 --- a/cmd/podman/images/exists.go +++ b/cmd/podman/images/exists.go @@ -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, }) diff --git a/cmd/podman/images/history.go b/cmd/podman/images/history.go index 16be0bb19..69268c261 100644 --- a/cmd/podman/images/history.go +++ b/cmd/podman/images/history.go @@ -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, }) diff --git a/cmd/podman/images/image.go b/cmd/podman/images/image.go index 69563959d..92d1348bf 100644 --- a/cmd/podman/images/image.go +++ b/cmd/podman/images/image.go @@ -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, }) } diff --git a/cmd/podman/images/images.go b/cmd/podman/images/images.go deleted file mode 100644 index 17fe21911..000000000 --- a/cmd/podman/images/images.go +++ /dev/null @@ -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) -} diff --git a/cmd/podman/images/import.go b/cmd/podman/images/import.go index 72e0b63ba..bed2d4105 100644 --- a/cmd/podman/images/import.go +++ b/cmd/podman/images/import.go @@ -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, }) diff --git a/cmd/podman/images/inspect.go b/cmd/podman/images/inspect.go index ac3becaa6..35c173a60 100644 --- a/cmd/podman/images/inspect.go +++ b/cmd/podman/images/inspect.go @@ -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, }) diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 132af858b..cc38a45c7 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -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) { diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go index aac95dae8..c7b7d6b3f 100644 --- a/cmd/podman/images/load.go +++ b/cmd/podman/images/load.go @@ -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, }) diff --git a/cmd/podman/images/mount.go b/cmd/podman/images/mount.go index a098aac63..efcff8264 100644 --- a/cmd/podman/images/mount.go +++ b/cmd/podman/images/mount.go @@ -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, }) diff --git a/cmd/podman/images/prune.go b/cmd/podman/images/prune.go index db645cc2e..a082255f6 100644 --- a/cmd/podman/images/prune.go +++ b/cmd/podman/images/prune.go @@ -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, }) diff --git a/cmd/podman/images/pull.go b/cmd/podman/images/pull.go index bf0eec759..a831ea848 100644 --- a/cmd/podman/images/pull.go +++ b/cmd/podman/images/pull.go @@ -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, }) diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go index 9e7b447a4..edf8e9203 100644 --- a/cmd/podman/images/push.go +++ b/cmd/podman/images/push.go @@ -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, }) diff --git a/cmd/podman/images/rm.go b/cmd/podman/images/rm.go index 2daa4743f..be4c0b883 100644 --- a/cmd/podman/images/rm.go +++ b/cmd/podman/images/rm.go @@ -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) { diff --git a/cmd/podman/images/rmi.go b/cmd/podman/images/rmi.go deleted file mode 100644 index edd6ae96f..000000000 --- a/cmd/podman/images/rmi.go +++ /dev/null @@ -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()) -} diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go index f1f7e8b2e..19dadb2ad 100644 --- a/cmd/podman/images/save.go +++ b/cmd/podman/images/save.go @@ -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, }) diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go index a3cfa983f..08bf3cf6b 100644 --- a/cmd/podman/images/search.go +++ b/cmd/podman/images/search.go @@ -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, }) diff --git a/cmd/podman/images/sign.go b/cmd/podman/images/sign.go index fcd904bb7..96f214d0b 100644 --- a/cmd/podman/images/sign.go +++ b/cmd/podman/images/sign.go @@ -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, }) diff --git a/cmd/podman/images/tag.go b/cmd/podman/images/tag.go index 695ca30ed..633368f50 100644 --- a/cmd/podman/images/tag.go +++ b/cmd/podman/images/tag.go @@ -10,26 +10,24 @@ import ( var ( tagDescription = "Adds one or more additional names to locally-stored image." tagCommand = &cobra.Command{ - Use: "tag IMAGE TARGET_NAME [TARGET_NAME...]", - Short: "Add an additional name to a local image", - Long: tagDescription, - RunE: tag, - Args: cobra.MinimumNArgs(2), - DisableFlagsInUseLine: true, - ValidArgsFunction: common.AutocompleteImages, + Use: "tag IMAGE TARGET_NAME [TARGET_NAME...]", + Short: "Add an additional name to a local image", + Long: tagDescription, + RunE: tag, + Args: cobra.MinimumNArgs(2), + ValidArgsFunction: common.AutocompleteImages, Example: `podman tag 0e3bbc2 fedora:latest podman tag imageID:latest myNewImage:newTag podman tag httpd myregistryhost:5000/fedora/httpd:v2`, } imageTagCommand = &cobra.Command{ - Args: tagCommand.Args, - DisableFlagsInUseLine: true, - Use: tagCommand.Use, - Short: tagCommand.Short, - Long: tagCommand.Long, - RunE: tagCommand.RunE, - ValidArgsFunction: tagCommand.ValidArgsFunction, + Args: tagCommand.Args, + Use: tagCommand.Use, + Short: tagCommand.Short, + Long: tagCommand.Long, + RunE: tagCommand.RunE, + ValidArgsFunction: tagCommand.ValidArgsFunction, Example: `podman image tag 0e3bbc2 fedora:latest podman image tag imageID:latest myNewImage:newTag podman image tag httpd myregistryhost:5000/fedora/httpd:v2`, @@ -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, }) diff --git a/cmd/podman/images/tree.go b/cmd/podman/images/tree.go index 0a659c914..8ace9d63c 100644 --- a/cmd/podman/images/tree.go +++ b/cmd/podman/images/tree.go @@ -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, }) diff --git a/cmd/podman/images/trust.go b/cmd/podman/images/trust.go index 2c51bb5f8..28eb53193 100644 --- a/cmd/podman/images/trust.go +++ b/cmd/podman/images/trust.go @@ -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,16 +10,16 @@ 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{ - Use: "trust", - Short: "Manage container image trust policy", - Long: trustDescription, - RunE: validate.SubCommandExists, + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, + Use: "trust", + Short: "Manage container image trust policy", + Long: trustDescription, + RunE: validate.SubCommandExists, } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode}, Command: trustCmd, Parent: imageCmd, }) diff --git a/cmd/podman/images/trust_set.go b/cmd/podman/images/trust_set.go index c192669a9..e01a04146 100644 --- a/cmd/podman/images/trust_set.go +++ b/cmd/podman/images/trust_set.go @@ -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, }) diff --git a/cmd/podman/images/trust_show.go b/cmd/podman/images/trust_show.go index ed9aecdb7..5d9376068 100644 --- a/cmd/podman/images/trust_show.go +++ b/cmd/podman/images/trust_show.go @@ -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, }) diff --git a/cmd/podman/images/unmount.go b/cmd/podman/images/unmount.go index 1e890c292..f72268ea2 100644 --- a/cmd/podman/images/unmount.go +++ b/cmd/podman/images/unmount.go @@ -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, }) diff --git a/cmd/podman/images/untag.go b/cmd/podman/images/untag.go index 4344e1847..4c1862242 100644 --- a/cmd/podman/images/untag.go +++ b/cmd/podman/images/untag.go @@ -8,27 +8,25 @@ import ( ) var ( - untagCommand = &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, + 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), + 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, }) } diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go index 13417c1ab..0c8102952 100644 --- a/cmd/podman/inspect.go +++ b/cmd/podman/inspect.go @@ -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) diff --git a/cmd/podman/login.go b/cmd/podman/login.go index cd3bc9756..2101e32e2 100644 --- a/cmd/podman/login.go +++ b/cmd/podman/login.go @@ -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() diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go index 286737b12..092ad2610 100644 --- a/cmd/podman/logout.go +++ b/cmd/podman/logout.go @@ -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() diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go index 02dfc80aa..f4133dbde 100644 --- a/cmd/podman/machine/init.go +++ b/cmd/podman/machine/init.go @@ -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" @@ -25,13 +24,12 @@ var ( ) var ( - initOpts = machine.InitOptions{} - defaultMachineName string = "podman-machine-default" + initOpts = machine.InitOptions{} + defaultMachineName = "podman-machine-default" ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: initCmd, Parent: machineCmd, }) diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go index af4e2c807..77b47161a 100644 --- a/cmd/podman/machine/list.go +++ b/cmd/podman/machine/list.go @@ -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" @@ -25,15 +24,15 @@ import ( var ( lsCmd = &cobra.Command{ - Use: "list [options]", - Aliases: []string{"ls"}, - Short: "List machines", - Long: "List managed virtual machines.", - RunE: list, - Args: validate.NoArgs, + Use: "list [options]", + Aliases: []string{"ls"}, + Short: "List machines", + 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, }) diff --git a/cmd/podman/machine/machine.go b/cmd/podman/machine/machine.go index d8cdf5568..b059afc38 100644 --- a/cmd/podman/machine/machine.go +++ b/cmd/podman/machine/machine.go @@ -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, }) } diff --git a/cmd/podman/machine/machine_unsupported.go b/cmd/podman/machine/machine_unsupported.go index 3bb44b51f..f8392694a 100644 --- a/cmd/podman/machine/machine_unsupported.go +++ b/cmd/podman/machine/machine_unsupported.go @@ -2,4 +2,5 @@ package machine +// init do not register _podman machine_ command on unsupported platforms func init() {} diff --git a/cmd/podman/machine/rm.go b/cmd/podman/machine/rm.go index 0be2ba40c..02e3dfeb8 100644 --- a/cmd/podman/machine/rm.go +++ b/cmd/podman/machine/rm.go @@ -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, }) diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go index ecc6d3b82..b52a48faf 100644 --- a/cmd/podman/machine/ssh.go +++ b/cmd/podman/machine/ssh.go @@ -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, }) diff --git a/cmd/podman/machine/start.go b/cmd/podman/machine/start.go index 4334cfc0f..f8f0eed09 100644 --- a/cmd/podman/machine/start.go +++ b/cmd/podman/machine/start.go @@ -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, }) diff --git a/cmd/podman/machine/stop.go b/cmd/podman/machine/stop.go index 4307d3eeb..2d5aa7b95 100644 --- a/cmd/podman/machine/stop.go +++ b/cmd/podman/machine/stop.go @@ -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, }) diff --git a/cmd/podman/main.go b/cmd/podman/main.go index 5219da26d..b7f5f1720 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -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,38 +43,41 @@ func main() { func parseCommands() *cobra.Command { cfg := registry.PodmanConfig() for _, c := range registry.Commands { - for _, m := range c.Mode { - if cfg.EngineMode == m { - // Command cannot be run rootless - _, found := c.Command.Annotations[registry.UnshareNSRequired] - if found { - if rootless.IsRootless() && found && 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()) - } - } - } else { - _, found = c.Command.Annotations[registry.ParentNSRequired] - if rootless.IsRootless() && found { - c.Command.RunE = func(cmd *cobra.Command, args []string) error { - return fmt.Errorf("cannot run command %q in rootless mode", cmd.CommandPath()) - } - } + 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() && 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()) } - parent := rootCmd - if c.Parent != nil { - parent = c.Parent + } + } else { + _, found = c.Command.Annotations[registry.ParentNSRequired] + if rootless.IsRootless() && found { + c.Command.RunE = func(cmd *cobra.Command, args []string) error { + return fmt.Errorf("cannot run command %q in rootless mode", cmd.CommandPath()) } - parent.AddCommand(c.Command) - - // - templates need to be set here, as PersistentPreRunE() is - // not called when --help is used. - // - rootCmd uses cobra default template not ours - c.Command.SetHelpTemplate(helpTemplate) - c.Command.SetUsageTemplate(usageTemplate) - c.Command.DisableFlagsInUseLine = true } } + + parent := rootCmd + if c.Parent != nil { + parent = c.Parent + } + parent.AddCommand(c.Command) + + // - templates need to be set here, as PersistentPreRunE() is + // not called when --help is used. + // - rootCmd uses cobra default template not ours + c.Command.SetHelpTemplate(helpTemplate) + c.Command.SetUsageTemplate(usageTemplate) + c.Command.DisableFlagsInUseLine = true } if err := terminal.SetConsole(); err != nil { logrus.Error(err) diff --git a/cmd/podman/manifest/add.go b/cmd/podman/manifest/add.go index 2499dc2e8..9d219601c 100644 --- a/cmd/podman/manifest/add.go +++ b/cmd/podman/manifest/add.go @@ -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, }) diff --git a/cmd/podman/manifest/annotate.go b/cmd/podman/manifest/annotate.go index f5ec13bf2..d806ce9e6 100644 --- a/cmd/podman/manifest/annotate.go +++ b/cmd/podman/manifest/annotate.go @@ -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, }) diff --git a/cmd/podman/manifest/create.go b/cmd/podman/manifest/create.go index a15b129d5..9f7d74d14 100644 --- a/cmd/podman/manifest/create.go +++ b/cmd/podman/manifest/create.go @@ -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, }) diff --git a/cmd/podman/manifest/exists.go b/cmd/podman/manifest/exists.go index 7fed1f25c..55318330d 100644 --- a/cmd/podman/manifest/exists.go +++ b/cmd/podman/manifest/exists.go @@ -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, }) diff --git a/cmd/podman/manifest/inspect.go b/cmd/podman/manifest/inspect.go index 118c0ae70..d444f9066 100644 --- a/cmd/podman/manifest/inspect.go +++ b/cmd/podman/manifest/inspect.go @@ -6,26 +6,23 @@ 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" ) var ( inspectCmd = &cobra.Command{ - Use: "inspect IMAGE", - Short: "Display the contents of a manifest list or image index", - Long: "Display the contents of a manifest list or image index.", - RunE: inspect, - ValidArgsFunction: common.AutocompleteImages, - Example: "podman manifest inspect localhost/list", - Args: cobra.ExactArgs(1), - DisableFlagsInUseLine: true, + Use: "inspect IMAGE", + Short: "Display the contents of a manifest list or image index", + Long: "Display the contents of a manifest list or image index.", + RunE: inspect, + ValidArgsFunction: common.AutocompleteImages, + Example: "podman manifest inspect localhost/list", + Args: cobra.ExactArgs(1), } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: inspectCmd, Parent: manifestCmd, }) diff --git a/cmd/podman/manifest/manifest.go b/cmd/podman/manifest/manifest.go index c725078bf..98d5199f1 100644 --- a/cmd/podman/manifest/manifest.go +++ b/cmd/podman/manifest/manifest.go @@ -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, }) } diff --git a/cmd/podman/manifest/push.go b/cmd/podman/manifest/push.go index 1dae5cc95..8b13f6dde 100644 --- a/cmd/podman/manifest/push.go +++ b/cmd/podman/manifest/push.go @@ -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, }) diff --git a/cmd/podman/manifest/remove.go b/cmd/podman/manifest/remove.go index 1d1128166..c44c0991e 100644 --- a/cmd/podman/manifest/remove.go +++ b/cmd/podman/manifest/remove.go @@ -6,27 +6,24 @@ 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" ) var ( removeCmd = &cobra.Command{ - Use: "remove LIST IMAGE", - Short: "Remove an entry from a manifest list or image index", - Long: "Removes an image from a manifest list or image index.", - RunE: remove, - ValidArgsFunction: common.AutocompleteImages, - Example: `podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`, - Args: cobra.ExactArgs(2), - DisableFlagsInUseLine: true, + Use: "remove LIST IMAGE", + Short: "Remove an entry from a manifest list or image index", + Long: "Removes an image from a manifest list or image index.", + RunE: remove, + ValidArgsFunction: common.AutocompleteImages, + Example: `podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`, + Args: cobra.ExactArgs(2), } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: removeCmd, Parent: manifestCmd, }) diff --git a/cmd/podman/manifest/rm.go b/cmd/podman/manifest/rm.go index 58c0de886..5e78197ed 100644 --- a/cmd/podman/manifest/rm.go +++ b/cmd/podman/manifest/rm.go @@ -6,27 +6,24 @@ 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" ) var ( rmCmd = &cobra.Command{ - Use: "rm LIST", - Short: "Remove manifest list or image index from local storage", - Long: "Remove manifest list or image index from local storage.", - RunE: rm, - ValidArgsFunction: common.AutocompleteImages, - Example: `podman manifest rm mylist:v1.11`, - Args: cobra.ExactArgs(1), - DisableFlagsInUseLine: true, + Use: "rm LIST", + Short: "Remove manifest list or image index from local storage", + Long: "Remove manifest list or image index from local storage.", + RunE: rm, + ValidArgsFunction: common.AutocompleteImages, + Example: `podman manifest rm mylist:v1.11`, + Args: cobra.ExactArgs(1), } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: rmCmd, Parent: manifestCmd, }) diff --git a/cmd/podman/networks/connect.go b/cmd/podman/networks/connect.go index 9fa088b78..0d62a45df 100644 --- a/cmd/podman/networks/connect.go +++ b/cmd/podman/networks/connect.go @@ -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, }) diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go index 64ca2464a..1f3b321ba 100644 --- a/cmd/podman/networks/create.go +++ b/cmd/podman/networks/create.go @@ -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, }) diff --git a/cmd/podman/networks/disconnect.go b/cmd/podman/networks/disconnect.go index 26861eec6..7f2ff4252 100644 --- a/cmd/podman/networks/disconnect.go +++ b/cmd/podman/networks/disconnect.go @@ -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, }) diff --git a/cmd/podman/networks/exists.go b/cmd/podman/networks/exists.go index fdbd0ef11..89466ab7f 100644 --- a/cmd/podman/networks/exists.go +++ b/cmd/podman/networks/exists.go @@ -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, }) diff --git a/cmd/podman/networks/inspect.go b/cmd/podman/networks/inspect.go index a05b9026d..c0e5b9720 100644 --- a/cmd/podman/networks/inspect.go +++ b/cmd/podman/networks/inspect.go @@ -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, }) diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go index e1b182cbf..46872d078 100644 --- a/cmd/podman/networks/list.go +++ b/cmd/podman/networks/list.go @@ -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, }) diff --git a/cmd/podman/networks/network.go b/cmd/podman/networks/network.go index 4d6cd8abd..ec045e3cf 100644 --- a/cmd/podman/networks/network.go +++ b/cmd/podman/networks/network.go @@ -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, }) } diff --git a/cmd/podman/networks/prune.go b/cmd/podman/networks/prune.go index 5f1cbda5f..e6b779ded 100644 --- a/cmd/podman/networks/prune.go +++ b/cmd/podman/networks/prune.go @@ -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, }) diff --git a/cmd/podman/networks/reload.go b/cmd/podman/networks/reload.go index 035e56a07..371bea9ef 100644 --- a/cmd/podman/networks/reload.go +++ b/cmd/podman/networks/reload.go @@ -15,10 +15,11 @@ import ( var ( networkReloadDescription = `reload container networks, recreating firewall rules` networkReloadCommand = &cobra.Command{ - Use: "reload [options] [CONTAINER...]", - Short: "Reload firewall rules for one or more containers", - Long: networkReloadDescription, - RunE: networkReload, + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, + Use: "reload [options] [CONTAINER...]", + Short: "Reload firewall rules for one or more containers", + Long: networkReloadDescription, + RunE: networkReload, Args: func(cmd *cobra.Command, args []string) error { return validate.CheckAllLatestAndCIDFile(cmd, args, false, false) }, @@ -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, }) diff --git a/cmd/podman/networks/rm.go b/cmd/podman/networks/rm.go index 1ae79b27d..14f9869e4 100644 --- a/cmd/podman/networks/rm.go +++ b/cmd/podman/networks/rm.go @@ -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, }) diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go index fe382bdfb..ece7d1f98 100644 --- a/cmd/podman/play/kube.go +++ b/cmd/podman/play/kube.go @@ -51,7 +51,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: kubeCmd, Parent: playCmd, }) diff --git a/cmd/podman/play/play.go b/cmd/podman/play/play.go index 89c7e0139..f121d6a2d 100644 --- a/cmd/podman/play/play.go +++ b/cmd/podman/play/play.go @@ -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/spf13/cobra" ) @@ -19,7 +18,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: playCmd, }) } diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go index 5600d8794..3c2c8a3bc 100644 --- a/cmd/podman/pods/create.go +++ b/cmd/podman/pods/create.go @@ -47,7 +47,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: createCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/exists.go b/cmd/podman/pods/exists.go index a9ef0370b..c4e64f88e 100644 --- a/cmd/podman/pods/exists.go +++ b/cmd/podman/pods/exists.go @@ -5,7 +5,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" ) @@ -21,13 +20,11 @@ var ( ValidArgsFunction: common.AutocompletePods, Example: `podman pod exists podID podman pod exists mypod || podman pod create --name mypod`, - DisableFlagsInUseLine: true, } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: existsCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go index c66b81adb..d38f0062c 100644 --- a/cmd/podman/pods/inspect.go +++ b/cmd/podman/pods/inspect.go @@ -37,7 +37,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: inspectCmd, Parent: podCmd, }) diff --git a/cmd/podman/pods/kill.go b/cmd/podman/pods/kill.go index 17d5499c8..66693b419 100644 --- a/cmd/podman/pods/kill.go +++ b/cmd/podman/pods/kill.go @@ -37,7 +37,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: killCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/pause.go b/cmd/podman/pods/pause.go index 6624ccbd7..c1cc151e0 100644 --- a/cmd/podman/pods/pause.go +++ b/cmd/podman/pods/pause.go @@ -37,7 +37,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: pauseCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/pod.go b/cmd/podman/pods/pod.go index 00fb02936..e6e23fd1f 100644 --- a/cmd/podman/pods/pod.go +++ b/cmd/podman/pods/pod.go @@ -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" ) @@ -24,7 +23,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: podCmd, }) } diff --git a/cmd/podman/pods/prune.go b/cmd/podman/pods/prune.go index 51b6bb4a9..8032c9f12 100644 --- a/cmd/podman/pods/prune.go +++ b/cmd/podman/pods/prune.go @@ -35,7 +35,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: pruneCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go index beaeda871..0271930e8 100644 --- a/cmd/podman/pods/ps.go +++ b/cmd/podman/pods/ps.go @@ -45,7 +45,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: psCmd, Parent: podCmd, }) diff --git a/cmd/podman/pods/restart.go b/cmd/podman/pods/restart.go index 5b9f47a5b..5b7ea121d 100644 --- a/cmd/podman/pods/restart.go +++ b/cmd/podman/pods/restart.go @@ -37,7 +37,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: restartCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/rm.go b/cmd/podman/pods/rm.go index 333e4eb9f..fbaf64c1f 100644 --- a/cmd/podman/pods/rm.go +++ b/cmd/podman/pods/rm.go @@ -45,7 +45,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: rmCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/start.go b/cmd/podman/pods/start.go index f6dca854e..e39891a9b 100644 --- a/cmd/podman/pods/start.go +++ b/cmd/podman/pods/start.go @@ -45,7 +45,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: startCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/stats.go b/cmd/podman/pods/stats.go index 97147275e..057b3dead 100644 --- a/cmd/podman/pods/stats.go +++ b/cmd/podman/pods/stats.go @@ -48,7 +48,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: statsCmd, Parent: podCmd, }) diff --git a/cmd/podman/pods/stop.go b/cmd/podman/pods/stop.go index a9a16b39c..bcc054b8e 100644 --- a/cmd/podman/pods/stop.go +++ b/cmd/podman/pods/stop.go @@ -46,7 +46,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: stopCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/top.go b/cmd/podman/pods/top.go index be8aab761..e26e281c8 100644 --- a/cmd/podman/pods/top.go +++ b/cmd/podman/pods/top.go @@ -39,7 +39,6 @@ podman pod top podID -eo user,pid,comm`, func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: topCommand, Parent: podCmd, }) diff --git a/cmd/podman/pods/unpause.go b/cmd/podman/pods/unpause.go index 859ac8ac2..ef1aea7c8 100644 --- a/cmd/podman/pods/unpause.go +++ b/cmd/podman/pods/unpause.go @@ -39,7 +39,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: unpauseCommand, Parent: podCmd, }) diff --git a/cmd/podman/registry/config.go b/cmd/podman/registry/config.go index 3ce6e3899..25139a3de 100644 --- a/cmd/podman/registry/config.go +++ b/cmd/podman/registry/config.go @@ -15,14 +15,25 @@ import ( ) const ( - ParentNSRequired = "ParentNSRequired" + // ParentNSRequired used as cobra.Annotation when command requires root access + ParentNSRequired = "ParentNSRequired" + + // UnshareNSRequired used as cobra.Annotation when command requires modified user namespace UnshareNSRequired = "UnshareNSRequired" + + // EngineMode used as cobra.Annotation when command supports a limited number of Engines + EngineMode = "EngineMode" ) var ( podmanOptions entities.PodmanConfig podmanSync sync.Once abiSupport = false + + // ABIMode used in cobra.Annotations registry.EngineMode when command only supports ABIMode + ABIMode = entities.ABIMode.String() + // TunnelMode used in in cobra.Annotations registry.EngineMode when command only supports TunnelMode + TunnelMode = entities.TunnelMode.String() ) // PodmanConfig returns an entities.PodmanConfig built up from diff --git a/cmd/podman/registry/registry.go b/cmd/podman/registry/registry.go index 0b1d9293a..607ef6d8e 100644 --- a/cmd/podman/registry/registry.go +++ b/cmd/podman/registry/registry.go @@ -19,7 +19,6 @@ const DefaultRootAPIPath = "/run/podman/podman.sock" const DefaultRootAPIAddress = "unix:" + DefaultRootAPIPath type CliCommand struct { - Mode []entities.EngineMode Command *cobra.Command Parent *cobra.Command } diff --git a/cmd/podman/secrets/create.go b/cmd/podman/secrets/create.go index 4204f30b4..f5739e99a 100644 --- a/cmd/podman/secrets/create.go +++ b/cmd/podman/secrets/create.go @@ -35,7 +35,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: createCmd, Parent: secretCmd, }) diff --git a/cmd/podman/secrets/inspect.go b/cmd/podman/secrets/inspect.go index bcb1adb5e..874456f29 100644 --- a/cmd/podman/secrets/inspect.go +++ b/cmd/podman/secrets/inspect.go @@ -33,7 +33,6 @@ var format string func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: inspectCmd, Parent: secretCmd, }) diff --git a/cmd/podman/secrets/list.go b/cmd/podman/secrets/list.go index ba7065d61..448a69994 100644 --- a/cmd/podman/secrets/list.go +++ b/cmd/podman/secrets/list.go @@ -39,7 +39,6 @@ type listFlagType struct { func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: lsCmd, Parent: secretCmd, }) diff --git a/cmd/podman/secrets/rm.go b/cmd/podman/secrets/rm.go index ade015b10..dd3f5d9b9 100644 --- a/cmd/podman/secrets/rm.go +++ b/cmd/podman/secrets/rm.go @@ -24,7 +24,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: rmCmd, Parent: secretCmd, }) diff --git a/cmd/podman/secrets/secret.go b/cmd/podman/secrets/secret.go index 139997b87..610b331d1 100644 --- a/cmd/podman/secrets/secret.go +++ b/cmd/podman/secrets/secret.go @@ -3,7 +3,6 @@ package secrets 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" ) @@ -19,7 +18,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: secretCmd, }) } diff --git a/cmd/podman/system/connection.go b/cmd/podman/system/connection.go index dbdda8cf9..1f8e8f13f 100644 --- a/cmd/podman/system/connection.go +++ b/cmd/podman/system/connection.go @@ -3,7 +3,6 @@ package system 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" ) @@ -14,20 +13,18 @@ var ( } ConnectionCmd = &cobra.Command{ - Use: "connection", - Short: "Manage remote ssh destinations", - Long: `Manage ssh destination information in podman configuration`, - DisableFlagsInUseLine: true, - PersistentPreRunE: noOp, - RunE: validate.SubCommandExists, - PersistentPostRunE: noOp, - TraverseChildren: false, + Use: "connection", + Short: "Manage remote ssh destinations", + Long: `Manage ssh destination information in podman configuration`, + PersistentPreRunE: noOp, + RunE: validate.SubCommandExists, + PersistentPostRunE: noOp, + TraverseChildren: false, } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: ConnectionCmd, Parent: systemCmd, }) diff --git a/cmd/podman/system/connection/add.go b/cmd/podman/system/connection/add.go index 89d28849c..ecfeb6608 100644 --- a/cmd/podman/system/connection/add.go +++ b/cmd/podman/system/connection/add.go @@ -15,7 +15,6 @@ import ( "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/system" "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/terminal" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -53,7 +52,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: addCmd, Parent: system.ConnectionCmd, }) diff --git a/cmd/podman/system/connection/default.go b/cmd/podman/system/connection/default.go index 073bdbc3f..cfedc337b 100644 --- a/cmd/podman/system/connection/default.go +++ b/cmd/podman/system/connection/default.go @@ -7,27 +7,24 @@ import ( "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/system" - "github.com/containers/podman/v3/pkg/domain/entities" "github.com/spf13/cobra" ) var ( // Skip creating engines since this command will obtain connection information to said engines dfltCmd = &cobra.Command{ - Use: "default NAME", - Args: cobra.ExactArgs(1), - Short: "Set named destination as default", - Long: `Set named destination as default for the Podman service`, - DisableFlagsInUseLine: true, - ValidArgsFunction: common.AutocompleteSystemConnections, - RunE: defaultRunE, - Example: `podman system connection default testing`, + Use: "default NAME", + Args: cobra.ExactArgs(1), + Short: "Set named destination as default", + Long: `Set named destination as default for the Podman service`, + ValidArgsFunction: common.AutocompleteSystemConnections, + RunE: defaultRunE, + Example: `podman system connection default testing`, } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: dfltCmd, Parent: system.ConnectionCmd, }) diff --git a/cmd/podman/system/connection/list.go b/cmd/podman/system/connection/list.go index fe7026ae3..ae88b0b30 100644 --- a/cmd/podman/system/connection/list.go +++ b/cmd/podman/system/connection/list.go @@ -10,18 +10,16 @@ import ( "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/system" "github.com/containers/podman/v3/cmd/podman/validate" - "github.com/containers/podman/v3/pkg/domain/entities" "github.com/spf13/cobra" ) var ( listCmd = &cobra.Command{ - Use: "list", - Aliases: []string{"ls"}, - Args: validate.NoArgs, - Short: "List destination for the Podman service(s)", - Long: `List destination information for the Podman service(s) in podman configuration`, - DisableFlagsInUseLine: true, + Use: "list", + Aliases: []string{"ls"}, + Args: validate.NoArgs, + Short: "List destination for the Podman service(s)", + Long: `List destination information for the Podman service(s) in podman configuration`, Example: `podman system connection list podman system connection ls`, ValidArgsFunction: completion.AutocompleteNone, @@ -32,7 +30,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: listCmd, Parent: system.ConnectionCmd, }) diff --git a/cmd/podman/system/connection/remove.go b/cmd/podman/system/connection/remove.go index 4acaa36a9..73bae4994 100644 --- a/cmd/podman/system/connection/remove.go +++ b/cmd/podman/system/connection/remove.go @@ -5,21 +5,19 @@ import ( "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/system" - "github.com/containers/podman/v3/pkg/domain/entities" "github.com/spf13/cobra" ) var ( // Skip creating engines since this command will obtain connection information to said engines rmCmd = &cobra.Command{ - Use: "remove NAME", - Args: cobra.ExactArgs(1), - Aliases: []string{"rm"}, - Long: `Delete named destination from podman configuration`, - Short: "Delete named destination", - DisableFlagsInUseLine: true, - ValidArgsFunction: common.AutocompleteSystemConnections, - RunE: rm, + Use: "remove NAME", + Args: cobra.ExactArgs(1), + Aliases: []string{"rm"}, + Long: `Delete named destination from podman configuration`, + Short: "Delete named destination", + ValidArgsFunction: common.AutocompleteSystemConnections, + RunE: rm, Example: `podman system connection remove devl podman system connection rm devl`, } @@ -27,7 +25,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: rmCmd, Parent: system.ConnectionCmd, }) diff --git a/cmd/podman/system/connection/rename.go b/cmd/podman/system/connection/rename.go index 7713c2b09..898457d38 100644 --- a/cmd/podman/system/connection/rename.go +++ b/cmd/podman/system/connection/rename.go @@ -7,21 +7,19 @@ import ( "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/system" - "github.com/containers/podman/v3/pkg/domain/entities" "github.com/spf13/cobra" ) var ( // Skip creating engines since this command will obtain connection information to said engines renameCmd = &cobra.Command{ - Use: "rename OLD NEW", - Aliases: []string{"mv"}, - Args: cobra.ExactArgs(2), - Short: "Rename \"old\" to \"new\"", - Long: `Rename destination for the Podman service from "old" to "new"`, - DisableFlagsInUseLine: true, - ValidArgsFunction: common.AutocompleteSystemConnections, - RunE: rename, + Use: "rename OLD NEW", + Aliases: []string{"mv"}, + Args: cobra.ExactArgs(2), + Short: "Rename \"old\" to \"new\"", + Long: `Rename destination for the Podman service from "old" to "new"`, + ValidArgsFunction: common.AutocompleteSystemConnections, + RunE: rename, Example: `podman system connection rename laptop devl, podman system connection mv laptop devl`, } @@ -29,7 +27,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: renameCmd, Parent: system.ConnectionCmd, }) diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go index 5e179a82d..de56c57d0 100644 --- a/cmd/podman/system/df.go +++ b/cmd/podman/system/df.go @@ -40,7 +40,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: dfSystemCommand, Parent: systemCmd, }) diff --git a/cmd/podman/system/events.go b/cmd/podman/system/events.go index 568610bdc..4aa413ec6 100644 --- a/cmd/podman/system/events.go +++ b/cmd/podman/system/events.go @@ -41,7 +41,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: eventsCommand, }) flags := eventsCommand.Flags() diff --git a/cmd/podman/system/info.go b/cmd/podman/system/info.go index 44be4ccec..1dc90f79a 100644 --- a/cmd/podman/system/info.go +++ b/cmd/podman/system/info.go @@ -11,7 +11,6 @@ import ( "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/cmd/podman/validate" "github.com/containers/podman/v3/libpod/define" - "github.com/containers/podman/v3/pkg/domain/entities" "github.com/ghodss/yaml" "github.com/spf13/cobra" ) @@ -49,13 +48,11 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: infoCommand, }) infoFlags(infoCommand) registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: systemInfoCommand, Parent: systemCmd, }) diff --git a/cmd/podman/system/migrate.go b/cmd/podman/system/migrate.go index 892d60a38..9940cd063 100644 --- a/cmd/podman/system/migrate.go +++ b/cmd/podman/system/migrate.go @@ -22,6 +22,7 @@ var ( ` migrateCommand = &cobra.Command{ + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, Use: "migrate [options]", Args: validate.NoArgs, Short: "Migrate containers", @@ -37,7 +38,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode}, Command: migrateCommand, Parent: systemCmd, }) diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index 0f1285564..e09e2d5e5 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -41,7 +41,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: pruneCommand, Parent: systemCmd, }) diff --git a/cmd/podman/system/renumber.go b/cmd/podman/system/renumber.go index 91c49333a..83a873c2a 100644 --- a/cmd/podman/system/renumber.go +++ b/cmd/podman/system/renumber.go @@ -23,19 +23,18 @@ var ( ` renumberCommand = &cobra.Command{ - Use: "renumber", - Args: validate.NoArgs, - DisableFlagsInUseLine: true, - Short: "Migrate lock numbers", - Long: renumberDescription, - Run: renumber, - ValidArgsFunction: completion.AutocompleteNone, + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, + Use: "renumber", + Args: validate.NoArgs, + Short: "Migrate lock numbers", + Long: renumberDescription, + Run: renumber, + ValidArgsFunction: completion.AutocompleteNone, } ) func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode}, Command: renumberCommand, Parent: systemCmd, }) diff --git a/cmd/podman/system/reset.go b/cmd/podman/system/reset.go index 6f2f873dd..0edb36889 100644 --- a/cmd/podman/system/reset.go +++ b/cmd/podman/system/reset.go @@ -23,6 +23,7 @@ var ( All containers will be stopped and removed, and all images, volumes and container content will be removed. ` systemResetCommand = &cobra.Command{ + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, Use: "reset [options]", Args: validate.NoArgs, Short: "Reset podman storage", @@ -36,7 +37,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode}, Command: systemResetCommand, Parent: systemCmd, }) diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go index 1e1cdbd12..63f2de51e 100644 --- a/cmd/podman/system/service.go +++ b/cmd/podman/system/service.go @@ -28,6 +28,7 @@ Enable a listening service for API access to Podman commands. ` srvCmd = &cobra.Command{ + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, Use: "service [options] [URI]", Args: cobra.MaximumNArgs(1), Short: "Run API service", @@ -44,7 +45,6 @@ Enable a listening service for API access to Podman commands. func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode}, Command: srvCmd, Parent: systemCmd, }) diff --git a/cmd/podman/system/system.go b/cmd/podman/system/system.go index ab06c3ae0..1947decaf 100644 --- a/cmd/podman/system/system.go +++ b/cmd/podman/system/system.go @@ -3,7 +3,6 @@ package system 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: systemCmd, }) } diff --git a/cmd/podman/system/unshare.go b/cmd/podman/system/unshare.go index c07751532..f930d8b62 100644 --- a/cmd/podman/system/unshare.go +++ b/cmd/podman/system/unshare.go @@ -15,12 +15,12 @@ var ( unshareOptions = entities.SystemUnshareOptions{} unshareDescription = "Runs a command in a modified user namespace." unshareCommand = &cobra.Command{ - Use: "unshare [options] [COMMAND [ARG...]]", - DisableFlagsInUseLine: true, - Short: "Run a command in a modified user namespace", - Long: unshareDescription, - RunE: unshare, - ValidArgsFunction: completion.AutocompleteDefault, + Annotations: map[string]string{registry.EngineMode: registry.ABIMode}, + Use: "unshare [options] [COMMAND [ARG...]]", + Short: "Run a command in a modified user namespace", + Long: unshareDescription, + RunE: unshare, + ValidArgsFunction: completion.AutocompleteDefault, Example: `podman unshare id podman unshare cat /proc/self/uid_map, podman unshare podman-script.sh`, @@ -29,7 +29,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode}, Command: unshareCommand, }) flags := unshareCommand.Flags() diff --git a/cmd/podman/system/version.go b/cmd/podman/system/version.go index ad9fd2a85..5575fc87d 100644 --- a/cmd/podman/system/version.go +++ b/cmd/podman/system/version.go @@ -31,7 +31,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: versionCommand, }) flags := versionCommand.Flags() diff --git a/cmd/podman/volumes/create.go b/cmd/podman/volumes/create.go index 1820260a4..70373d69d 100644 --- a/cmd/podman/volumes/create.go +++ b/cmd/podman/volumes/create.go @@ -37,7 +37,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: createCommand, Parent: volumeCmd, }) diff --git a/cmd/podman/volumes/exists.go b/cmd/podman/volumes/exists.go index 4dfbb3cd4..85bbcb29a 100644 --- a/cmd/podman/volumes/exists.go +++ b/cmd/podman/volumes/exists.go @@ -3,7 +3,6 @@ package volumes 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: volumeExistsCommand, Parent: volumeCmd, }) diff --git a/cmd/podman/volumes/inspect.go b/cmd/podman/volumes/inspect.go index d52eee9f3..7510f8a1c 100644 --- a/cmd/podman/volumes/inspect.go +++ b/cmd/podman/volumes/inspect.go @@ -32,7 +32,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: inspectCommand, Parent: volumeCmd, }) diff --git a/cmd/podman/volumes/list.go b/cmd/podman/volumes/list.go index f402afa94..990b39435 100644 --- a/cmd/podman/volumes/list.go +++ b/cmd/podman/volumes/list.go @@ -49,7 +49,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: lsCommand, Parent: volumeCmd, }) diff --git a/cmd/podman/volumes/prune.go b/cmd/podman/volumes/prune.go index 8e190b870..1f3cc6913 100644 --- a/cmd/podman/volumes/prune.go +++ b/cmd/podman/volumes/prune.go @@ -35,7 +35,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: pruneCommand, Parent: volumeCmd, }) diff --git a/cmd/podman/volumes/rm.go b/cmd/podman/volumes/rm.go index e149e398c..9ba4a30a1 100644 --- a/cmd/podman/volumes/rm.go +++ b/cmd/podman/volumes/rm.go @@ -37,7 +37,6 @@ var ( func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ - Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: rmCommand, Parent: volumeCmd, }) diff --git a/cmd/podman/volumes/volume.go b/cmd/podman/volumes/volume.go index 7786d5dc3..f42a6d81a 100644 --- a/cmd/podman/volumes/volume.go +++ b/cmd/podman/volumes/volume.go @@ -3,7 +3,6 @@ package volumes 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: volumeCmd, }) } -- cgit v1.2.3-54-g00ecf