summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common/completion.go78
-rw-r--r--cmd/podman/common/create_opts.go2
-rw-r--r--cmd/podman/common/specgen.go7
-rw-r--r--cmd/podman/containers/commit.go2
-rw-r--r--cmd/podman/containers/cp.go2
-rw-r--r--cmd/podman/containers/exec.go2
-rw-r--r--cmd/podman/containers/logs.go6
-rw-r--r--cmd/podman/containers/port.go2
-rw-r--r--cmd/podman/containers/prune.go2
-rw-r--r--cmd/podman/containers/runlabel.go2
-rw-r--r--cmd/podman/diff.go2
-rw-r--r--cmd/podman/generate/kube.go8
-rw-r--r--cmd/podman/generate/systemd.go2
-rw-r--r--cmd/podman/images/build.go10
-rw-r--r--cmd/podman/images/import.go5
-rw-r--r--cmd/podman/images/prune.go2
-rw-r--r--cmd/podman/images/push.go2
-rw-r--r--cmd/podman/images/save.go2
-rw-r--r--cmd/podman/images/untag.go2
-rw-r--r--cmd/podman/inspect.go4
-rw-r--r--cmd/podman/inspect/inspect.go11
-rw-r--r--cmd/podman/manifest/push.go2
-rw-r--r--cmd/podman/networks/create.go2
-rw-r--r--cmd/podman/networks/reload.go69
-rw-r--r--cmd/podman/play/kube.go2
-rw-r--r--cmd/podman/pods/prune.go6
-rw-r--r--cmd/podman/system/prune.go19
-rw-r--r--cmd/podman/system/service.go3
-rw-r--r--cmd/podman/system/unshare.go2
-rw-r--r--cmd/podman/utils/utils.go20
-rw-r--r--cmd/podman/volumes/prune.go2
31 files changed, 230 insertions, 52 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index 25f4d0f79..f792b2713 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -278,7 +278,6 @@ func validCurrentCmdLine(cmd *cobra.Command, args []string, toComplete string) b
return true
}
}
- cobra.CompDebugln(err.Error(), true)
return false
}
return true
@@ -445,6 +444,29 @@ func AutocompleteNetworks(cmd *cobra.Command, args []string, toComplete string)
return getNetworks(cmd, toComplete)
}
+// AutocompleteDefaultOneArg - Autocomplete path only for the first argument.
+func AutocompleteDefaultOneArg(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ if len(args) == 0 {
+ return nil, cobra.ShellCompDirectiveDefault
+ }
+ return nil, cobra.ShellCompDirectiveNoFileComp
+}
+
+// AutocompleteCommitCommand - Autocomplete podman commit command args.
+func AutocompleteCommitCommand(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ if !validCurrentCmdLine(cmd, args, toComplete) {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+ if len(args) == 0 {
+ return getContainers(cmd, toComplete, completeDefault)
+ }
+ if len(args) == 1 {
+ return getImages(cmd, toComplete)
+ }
+ // don't complete more than 2 args
+ return nil, cobra.ShellCompDirectiveNoFileComp
+}
+
// AutocompleteCpCommand - Autocomplete podman cp command args.
func AutocompleteCpCommand(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if !validCurrentCmdLine(cmd, args, toComplete) {
@@ -465,6 +487,43 @@ func AutocompleteCpCommand(cmd *cobra.Command, args []string, toComplete string)
return nil, cobra.ShellCompDirectiveNoFileComp
}
+// AutocompleteExecCommand - Autocomplete podman exec command args.
+func AutocompleteExecCommand(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ if !validCurrentCmdLine(cmd, args, toComplete) {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+ if len(args) == 0 {
+ return getContainers(cmd, toComplete, completeDefault, "running")
+ }
+ return nil, cobra.ShellCompDirectiveDefault
+}
+
+// AutocompleteRunlabelCommand - Autocomplete podman container runlabel command args.
+func AutocompleteRunlabelCommand(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ if !validCurrentCmdLine(cmd, args, toComplete) {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+ if len(args) == 0 {
+ // FIXME: What labels can we recommend here?
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+ if len(args) == 1 {
+ return getImages(cmd, toComplete)
+ }
+ return nil, cobra.ShellCompDirectiveDefault
+}
+
+// AutocompletePortCommand - Autocomplete podman port command args.
+func AutocompletePortCommand(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ if !validCurrentCmdLine(cmd, args, toComplete) {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+ if len(args) == 0 {
+ return getContainers(cmd, toComplete, completeDefault)
+ }
+ return nil, cobra.ShellCompDirectiveNoFileComp
+}
+
// AutocompleteNetworkConnectCmd - Autocomplete podman network connect/disconnect command args.
func AutocompleteNetworkConnectCmd(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
@@ -496,6 +555,23 @@ func AutocompleteTopCmd(cmd *cobra.Command, args []string, toComplete string) ([
return descriptors, cobra.ShellCompDirectiveNoFileComp
}
+// AutocompleteInspect - Autocomplete podman inspect.
+func AutocompleteInspect(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ if !validCurrentCmdLine(cmd, args, toComplete) {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+ containers, _ := getContainers(cmd, toComplete, completeDefault)
+ images, _ := getImages(cmd, toComplete)
+ pods, _ := getPods(cmd, toComplete, completeDefault)
+ networks, _ := getNetworks(cmd, toComplete)
+ volumes, _ := getVolumes(cmd, toComplete)
+ suggestions := append(containers, images...)
+ suggestions = append(suggestions, pods...)
+ suggestions = append(suggestions, networks...)
+ suggestions = append(suggestions, volumes...)
+ return suggestions, cobra.ShellCompDirectiveNoFileComp
+}
+
// AutocompleteSystemConnections - Autocomplete system connections.
func AutocompleteSystemConnections(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if !validCurrentCmdLine(cmd, args, toComplete) {
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 4b0e40df2..e975def0a 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -237,7 +237,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
}
// netMode
- nsmode, _, err := specgen.ParseNetworkNamespace(cc.HostConfig.NetworkMode.NetworkName())
+ nsmode, _, err := specgen.ParseNetworkNamespace(string(cc.HostConfig.NetworkMode))
if err != nil {
return nil, nil, err
}
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index e0da142ad..c416d0d7b 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -531,6 +531,13 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
case "seccomp":
s.SeccompProfilePath = con[1]
s.Annotations[define.InspectAnnotationSeccomp] = con[1]
+ // this option is for docker compatibility, it is the same as unmask=ALL
+ case "systempaths":
+ if con[1] == "unconfined" {
+ s.ContainerSecurityConfig.Unmask = append(s.ContainerSecurityConfig.Unmask, []string{"ALL"}...)
+ } else {
+ return fmt.Errorf("invalid systempaths option %q, only `unconfined` is supported", con[1])
+ }
case "unmask":
s.ContainerSecurityConfig.Unmask = append(s.ContainerSecurityConfig.Unmask, strings.Split(con[1], ":")...)
default:
diff --git a/cmd/podman/containers/commit.go b/cmd/podman/containers/commit.go
index c5c7673b2..ff06e10f7 100644
--- a/cmd/podman/containers/commit.go
+++ b/cmd/podman/containers/commit.go
@@ -24,7 +24,7 @@ var (
Long: commitDescription,
RunE: commit,
Args: cobra.RangeArgs(1, 2),
- ValidArgsFunction: common.AutocompleteContainers,
+ ValidArgsFunction: common.AutocompleteCommitCommand,
Example: `podman commit -q --message "committing container to image" reverent_golick image-committed
podman commit -q --author "firstName lastName" reverent_golick image-committed
podman commit -q --pause=false containerID image-committed
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
index fd3aa7680..9b0a01a2f 100644
--- a/cmd/podman/containers/cp.go
+++ b/cmd/podman/containers/cp.go
@@ -13,7 +13,7 @@ var (
You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container. If "-" is specified for either the SRC_PATH or DEST_PATH, you can also stream a tar archive from STDIN or to STDOUT. The CONTAINER can be a running or stopped container. The SRC_PATH or DEST_PATH can be a file or directory.
`
cpCommand = &cobra.Command{
- Use: "cp [options] SRC_PATH DEST_PATH",
+ Use: "cp [options] [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH",
Short: "Copy files/folders between a container and the local filesystem",
Long: cpDescription,
Args: cobra.ExactArgs(2),
diff --git a/cmd/podman/containers/exec.go b/cmd/podman/containers/exec.go
index 306bae58e..3d4918d50 100644
--- a/cmd/podman/containers/exec.go
+++ b/cmd/podman/containers/exec.go
@@ -26,7 +26,7 @@ var (
Long: execDescription,
RunE: exec,
DisableFlagsInUseLine: true,
- ValidArgsFunction: common.AutocompleteContainersRunning,
+ ValidArgsFunction: common.AutocompleteExecCommand,
Example: `podman exec -it ctrID ls
podman exec -it -w /tmp myCtr pwd
podman exec --user root ctrID ls`,
diff --git a/cmd/podman/containers/logs.go b/cmd/podman/containers/logs.go
index 1fa4ac11f..d4ede370a 100644
--- a/cmd/podman/containers/logs.go
+++ b/cmd/podman/containers/logs.go
@@ -69,6 +69,12 @@ var (
)
func init() {
+ // if run remotely we only allow one container arg
+ if registry.IsRemote() {
+ logsCommand.Use = "logs [options] CONTAINER"
+ containerLogsCommand.Use = logsCommand.Use
+ }
+
// logs
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
diff --git a/cmd/podman/containers/port.go b/cmd/podman/containers/port.go
index ac31e158e..d59161149 100644
--- a/cmd/podman/containers/port.go
+++ b/cmd/podman/containers/port.go
@@ -26,7 +26,7 @@ var (
Args: func(cmd *cobra.Command, args []string) error {
return validate.CheckAllLatestAndCIDFile(cmd, args, true, false)
},
- ValidArgsFunction: common.AutocompleteContainers,
+ ValidArgsFunction: common.AutocompletePortCommand,
Example: `podman port --all
podman port ctrID 80/tcp
podman port --latest 80`,
diff --git a/cmd/podman/containers/prune.go b/cmd/podman/containers/prune.go
index 9ac529b1c..d3842778b 100644
--- a/cmd/podman/containers/prune.go
+++ b/cmd/podman/containers/prune.go
@@ -78,5 +78,5 @@ func prune(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- return utils.PrintContainerPruneResults(responses)
+ return utils.PrintContainerPruneResults(responses, false)
}
diff --git a/cmd/podman/containers/runlabel.go b/cmd/podman/containers/runlabel.go
index 2f6d2eb05..6ebba4935 100644
--- a/cmd/podman/containers/runlabel.go
+++ b/cmd/podman/containers/runlabel.go
@@ -30,7 +30,7 @@ var (
Long: runlabelDescription,
RunE: runlabel,
Args: cobra.MinimumNArgs(2),
- ValidArgsFunction: common.AutocompleteImages,
+ ValidArgsFunction: common.AutocompleteRunlabelCommand,
Example: `podman container runlabel run imageID
podman container runlabel install imageID arg1 arg2
podman container runlabel --display run myImage`,
diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go
index 5e6abe243..e094e6bdd 100644
--- a/cmd/podman/diff.go
+++ b/cmd/podman/diff.go
@@ -18,7 +18,7 @@ var (
// Command: podman _diff_ Object_ID
diffDescription = `Displays changes on a container or image's filesystem. The container or image will be compared to its parent layer.`
diffCmd = &cobra.Command{
- Use: "diff [options] {CONTAINER_ID | IMAGE_ID}",
+ Use: "diff [options] {CONTAINER|IMAGE}",
Args: validate.IDOrLatestArgs,
Short: "Display the changes to the object's file system",
Long: diffDescription,
diff --git a/cmd/podman/generate/kube.go b/cmd/podman/generate/kube.go
index e47bd35b5..cb608e7b5 100644
--- a/cmd/podman/generate/kube.go
+++ b/cmd/podman/generate/kube.go
@@ -17,16 +17,16 @@ import (
var (
kubeOptions = entities.GenerateKubeOptions{}
kubeFile = ""
- kubeDescription = `Command generates Kubernetes pod and service YAML (v1 specification) from a Podman container or pod.
+ kubeDescription = `Command generates Kubernetes pod and service YAML (v1 specification) from Podman containers or a pod.
Whether the input is for a container or pod, Podman will always generate the specification as a pod.`
kubeCmd = &cobra.Command{
- Use: "kube [options] CONTAINER | POD",
+ Use: "kube [options] {CONTAINER...|POD}",
Short: "Generate Kubernetes YAML from a container or pod.",
Long: kubeDescription,
RunE: kube,
- Args: cobra.ExactArgs(1),
+ Args: cobra.MinimumNArgs(1),
ValidArgsFunction: common.AutocompleteContainersAndPods,
Example: `podman generate kube ctrID
podman generate kube podID
@@ -51,7 +51,7 @@ func init() {
}
func kube(cmd *cobra.Command, args []string) error {
- report, err := registry.ContainerEngine().GenerateKube(registry.GetContext(), args[0], kubeOptions)
+ report, err := registry.ContainerEngine().GenerateKube(registry.GetContext(), args, kubeOptions)
if err != nil {
return err
}
diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go
index e9cf76aae..f9099d3b8 100644
--- a/cmd/podman/generate/systemd.go
+++ b/cmd/podman/generate/systemd.go
@@ -26,7 +26,7 @@ var (
The generated units can later be controlled via systemctl(1).`
systemdCmd = &cobra.Command{
- Use: "systemd [options] CTR|POD",
+ Use: "systemd [options] {CONTAINER|POD}",
Short: "Generate systemd units.",
Long: systemdDescription,
RunE: systemd,
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 739e1c265..fbea1e3d8 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -11,6 +11,7 @@ import (
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config"
+ "github.com/containers/podman/v2/cmd/podman/common"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/utils"
"github.com/containers/podman/v2/pkg/domain/entities"
@@ -44,7 +45,7 @@ var (
Long: buildDescription,
Args: cobra.MaximumNArgs(1),
RunE: build,
- ValidArgsFunction: completion.AutocompleteDefault,
+ ValidArgsFunction: common.AutocompleteDefaultOneArg,
Example: `podman build .
podman build --creds=username:password -t imageName -f Containerfile.simple .
podman build --layers --force-rm --tag imageName .`,
@@ -115,6 +116,7 @@ func buildFlags(cmd *cobra.Command) {
// --layers flag
flag = layerFlags.Lookup("layers")
useLayersVal := useLayers()
+ buildOpts.Layers = useLayersVal == "true"
if err := flag.Value.Set(useLayersVal); err != nil {
logrus.Errorf("unable to set --layers to %v: %v", useLayersVal, err)
}
@@ -274,11 +276,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}
}
- // Check to see if the BUILDAH_LAYERS environment variable is set and
- // override command-line.
- if _, ok := os.LookupEnv("BUILDAH_LAYERS"); ok {
- flags.Layers = true
- }
+ flags.Layers = buildOpts.Layers
// `buildah bud --layers=false` acts like `docker build --squash` does.
// That is all of the new layers created during the build process are
diff --git a/cmd/podman/images/import.go b/cmd/podman/images/import.go
index f38ab3b19..ac59935ad 100644
--- a/cmd/podman/images/import.go
+++ b/cmd/podman/images/import.go
@@ -25,18 +25,19 @@ var (
Short: "Import a tarball to create a filesystem image",
Long: importDescription,
RunE: importCon,
- ValidArgsFunction: completion.AutocompleteDefault,
+ Args: cobra.RangeArgs(1, 2),
+ ValidArgsFunction: common.AutocompleteDefaultOneArg,
Example: `podman import http://example.com/ctr.tar url-image
cat ctr.tar | podman -q import --message "importing the ctr.tar tarball" - image-imported
cat ctr.tar | podman import -`,
}
imageImportCommand = &cobra.Command{
- Args: cobra.MinimumNArgs(1),
Use: importCommand.Use,
Short: importCommand.Short,
Long: importCommand.Long,
RunE: importCommand.RunE,
+ Args: importCommand.Args,
ValidArgsFunction: importCommand.ValidArgsFunction,
Example: `podman image import http://example.com/ctr.tar url-image
cat ctr.tar | podman -q image import --message "importing the ctr.tar tarball" - image-imported
diff --git a/cmd/podman/images/prune.go b/cmd/podman/images/prune.go
index e68fe5f40..268a68681 100644
--- a/cmd/podman/images/prune.go
+++ b/cmd/podman/images/prune.go
@@ -71,5 +71,5 @@ Are you sure you want to continue? [y/N] `)
return err
}
- return utils.PrintImagePruneResults(results)
+ return utils.PrintImagePruneResults(results, false)
}
diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go
index 447b02fbe..d82083cd8 100644
--- a/cmd/podman/images/push.go
+++ b/cmd/podman/images/push.go
@@ -29,7 +29,7 @@ var (
// Command: podman push
pushCmd = &cobra.Command{
- Use: "push [options] SOURCE [DESTINATION]",
+ Use: "push [options] IMAGE [DESTINATION]",
Short: "Push an image to a specified destination",
Long: pushDescription,
RunE: imagePush,
diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go
index 9ef2d0c91..3a35c4fad 100644
--- a/cmd/podman/images/save.go
+++ b/cmd/podman/images/save.go
@@ -43,7 +43,7 @@ var (
}
return nil
},
- ValidArgsFunction: completion.AutocompleteNone,
+ ValidArgsFunction: common.AutocompleteImages,
Example: `podman save --quiet -o myimage.tar imageID
podman save --format docker-dir -o ubuntu-dir ubuntu
podman save > alpine-all.tar alpine:latest`,
diff --git a/cmd/podman/images/untag.go b/cmd/podman/images/untag.go
index 17dc21203..3cf62713b 100644
--- a/cmd/podman/images/untag.go
+++ b/cmd/podman/images/untag.go
@@ -9,7 +9,7 @@ import (
var (
untagCommand = &cobra.Command{
- Use: "untag IMAGE [NAME...]",
+ 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,
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index f62abe931..64daae951 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -20,12 +20,12 @@ var (
// Command: podman _inspect_ Object_ID
inspectCmd = &cobra.Command{
- Use: "inspect [options] {CONTAINER_ID | IMAGE_ID} [...]",
+ Use: "inspect [options] {CONTAINER|IMAGE|POD|NETWORK|VOLUME} [...]",
Short: "Display the configuration of object denoted by ID",
RunE: inspectExec,
Long: inspectDescription,
TraverseChildren: true,
- ValidArgsFunction: common.AutocompleteContainersAndImages,
+ ValidArgsFunction: common.AutocompleteInspect,
Example: `podman inspect fedora
podman inspect --type image fedora
podman inspect CtrID ImgID
diff --git a/cmd/podman/inspect/inspect.go b/cmd/podman/inspect/inspect.go
index 13f36ebbd..cc48b7ae4 100644
--- a/cmd/podman/inspect/inspect.go
+++ b/cmd/podman/inspect/inspect.go
@@ -1,6 +1,7 @@
package inspect
import (
+ "bytes"
"context"
"encoding/json" // due to a bug in json-iterator it cannot be used here
"fmt"
@@ -245,7 +246,15 @@ func printJSON(data []interface{}) error {
}
func printTmpl(typ, row string, data []interface{}) error {
- t, err := template.New(typ + " inspect").Parse(row)
+ t, err := template.New(typ + " inspect").Funcs(map[string]interface{}{
+ "json": func(v interface{}) string {
+ b := &bytes.Buffer{}
+ e := registry.JSONLibrary().NewEncoder(b)
+ e.SetEscapeHTML(false)
+ _ = e.Encode(v)
+ return strings.TrimSpace(b.String())
+ },
+ }).Parse(row)
if err != nil {
return err
}
diff --git a/cmd/podman/manifest/push.go b/cmd/podman/manifest/push.go
index a3b469491..89faa42a2 100644
--- a/cmd/podman/manifest/push.go
+++ b/cmd/podman/manifest/push.go
@@ -24,7 +24,7 @@ type manifestPushOptsWrapper struct {
var (
manifestPushOpts = manifestPushOptsWrapper{}
pushCmd = &cobra.Command{
- Use: "push [options] SOURCE DESTINATION",
+ Use: "push [options] LIST DESTINATION",
Short: "Push a manifest list or image index to a registry",
Long: "Pushes manifest lists and image indexes to registries.",
RunE: push,
diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go
index 8db4bb89a..1a091f111 100644
--- a/cmd/podman/networks/create.go
+++ b/cmd/podman/networks/create.go
@@ -17,7 +17,7 @@ import (
var (
networkCreateDescription = `create CNI networks for containers and pods`
networkCreateCommand = &cobra.Command{
- Use: "create [options] [NETWORK]",
+ Use: "create [options] [NAME]",
Short: "network create",
Long: networkCreateDescription,
RunE: networkCreate,
diff --git a/cmd/podman/networks/reload.go b/cmd/podman/networks/reload.go
new file mode 100644
index 000000000..16655c18c
--- /dev/null
+++ b/cmd/podman/networks/reload.go
@@ -0,0 +1,69 @@
+package network
+
+import (
+ "fmt"
+
+ "github.com/containers/podman/v2/cmd/podman/common"
+ "github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/utils"
+ "github.com/containers/podman/v2/cmd/podman/validate"
+ "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/spf13/cobra"
+ "github.com/spf13/pflag"
+)
+
+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,
+ Args: func(cmd *cobra.Command, args []string) error {
+ return validate.CheckAllLatestAndCIDFile(cmd, args, false, false)
+ },
+ ValidArgsFunction: common.AutocompleteContainers,
+ Example: `podman network reload --latest
+ podman network reload 3c13ef6dd843
+ podman network reload test1 test2`,
+ Annotations: map[string]string{
+ registry.ParentNSRequired: "",
+ },
+ }
+)
+
+var (
+ reloadOptions entities.NetworkReloadOptions
+)
+
+func reloadFlags(flags *pflag.FlagSet) {
+ flags.BoolVarP(&reloadOptions.All, "all", "a", false, "Reload network configuration of all containers")
+}
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: networkReloadCommand,
+ Parent: networkCmd,
+ })
+ reloadFlags(networkReloadCommand.Flags())
+ validate.AddLatestFlag(networkReloadCommand, &reloadOptions.Latest)
+}
+
+func networkReload(cmd *cobra.Command, args []string) error {
+ responses, err := registry.ContainerEngine().NetworkReload(registry.Context(), args, reloadOptions)
+ if err != nil {
+ return err
+ }
+
+ var errs utils.OutputErrors
+ for _, r := range responses {
+ if r.Err == nil {
+ fmt.Println(r.Id)
+ } else {
+ errs = append(errs, r.Err)
+ }
+ }
+
+ return errs.PrintErrors()
+}
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index db70ad7d4..5e227d05a 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -39,7 +39,7 @@ var (
Long: kubeDescription,
RunE: kube,
Args: cobra.ExactArgs(1),
- ValidArgsFunction: completion.AutocompleteDefault,
+ ValidArgsFunction: common.AutocompleteDefaultOneArg,
Example: `podman play kube nginx.yml
podman play kube --creds user:password --seccomp-profile-root /custom/path apache.yml`,
}
diff --git a/cmd/podman/pods/prune.go b/cmd/podman/pods/prune.go
index 444b0f5e0..965c36398 100644
--- a/cmd/podman/pods/prune.go
+++ b/cmd/podman/pods/prune.go
@@ -7,7 +7,7 @@ import (
"os"
"strings"
- "github.com/containers/podman/v2/cmd/podman/common"
+ "github.com/containers/common/pkg/completion"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/utils"
"github.com/containers/podman/v2/cmd/podman/validate"
@@ -28,7 +28,7 @@ var (
Short: "Remove all stopped pods and their containers",
Long: pruneDescription,
RunE: prune,
- ValidArgsFunction: common.AutocompletePods,
+ ValidArgsFunction: completion.AutocompleteNone,
Example: `podman pod prune`,
}
)
@@ -60,5 +60,5 @@ func prune(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- return utils.PrintPodPruneResults(responses)
+ return utils.PrintPodPruneResults(responses, false)
}
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go
index f2b9a3db5..f57689584 100644
--- a/cmd/podman/system/prune.go
+++ b/cmd/podman/system/prune.go
@@ -73,32 +73,31 @@ Are you sure you want to continue? [y/N] `, volumeString)
return nil
}
}
+
// TODO: support for filters in system prune
response, err := registry.ContainerEngine().SystemPrune(context.Background(), pruneOptions)
if err != nil {
return err
}
- // Print pod prune results
- fmt.Println("Deleted Pods")
- err = utils.PrintPodPruneResults(response.PodPruneReport)
+ // Print container prune results
+ err = utils.PrintContainerPruneResults(response.ContainerPruneReport, true)
if err != nil {
return err
}
- // Print container prune results
- fmt.Println("Deleted Containers")
- err = utils.PrintContainerPruneResults(response.ContainerPruneReport)
+ // Print pod prune results
+ err = utils.PrintPodPruneResults(response.PodPruneReport, true)
if err != nil {
return err
}
// Print Volume prune results
if pruneOptions.Volume {
- fmt.Println("Deleted Volumes")
- err = utils.PrintVolumePruneResults(response.VolumePruneReport)
+ err = utils.PrintVolumePruneResults(response.VolumePruneReport, true)
if err != nil {
return err
}
}
// Print Images prune results
- fmt.Println("Deleted Images")
- return utils.PrintImagePruneResults(response.ImagePruneReport)
+ utils.PrintImagePruneResults(response.ImagePruneReport, true)
+
+ return nil
}
diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go
index 42482b5d9..f8bdbfa10 100644
--- a/cmd/podman/system/service.go
+++ b/cmd/podman/system/service.go
@@ -10,6 +10,7 @@ import (
"time"
"github.com/containers/common/pkg/completion"
+ "github.com/containers/podman/v2/cmd/podman/common"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/rootless"
@@ -32,7 +33,7 @@ Enable a listening service for API access to Podman commands.
Short: "Run API service",
Long: srvDescription,
RunE: service,
- ValidArgsFunction: completion.AutocompleteDefault,
+ ValidArgsFunction: common.AutocompleteDefaultOneArg,
Example: `podman system service --time=0 unix:///tmp/podman.sock`,
}
diff --git a/cmd/podman/system/unshare.go b/cmd/podman/system/unshare.go
index 437cf7b2e..364852979 100644
--- a/cmd/podman/system/unshare.go
+++ b/cmd/podman/system/unshare.go
@@ -14,7 +14,7 @@ import (
var (
unshareDescription = "Runs a command in a modified user namespace."
unshareCommand = &cobra.Command{
- Use: "unshare [COMMAND [ARG ...]]",
+ Use: "unshare [COMMAND [ARG...]]",
DisableFlagsInUseLine: true,
Short: "Run a command in a modified user namespace",
Long: unshareDescription,
diff --git a/cmd/podman/utils/utils.go b/cmd/podman/utils/utils.go
index 1c9e4d786..2ca2c4c92 100644
--- a/cmd/podman/utils/utils.go
+++ b/cmd/podman/utils/utils.go
@@ -26,8 +26,11 @@ func FileExists(path string) bool {
return !file.IsDir()
}
-func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport) error {
+func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport, heading bool) error {
var errs OutputErrors
+ if heading && len(podPruneReports) > 0 {
+ fmt.Println("Deleted Pods")
+ }
for _, r := range podPruneReports {
if r.Err == nil {
fmt.Println(r.Id)
@@ -38,8 +41,11 @@ func PrintPodPruneResults(podPruneReports []*entities.PodPruneReport) error {
return errs.PrintErrors()
}
-func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneReport) error {
+func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneReport, heading bool) error {
var errs OutputErrors
+ if heading && (len(containerPruneReport.ID) > 0 || len(containerPruneReport.Err) > 0) {
+ fmt.Println("Deleted Containers")
+ }
for k := range containerPruneReport.ID {
fmt.Println(k)
}
@@ -49,8 +55,11 @@ func PrintContainerPruneResults(containerPruneReport *entities.ContainerPruneRep
return errs.PrintErrors()
}
-func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport) error {
+func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport, heading bool) error {
var errs OutputErrors
+ if heading && len(volumePruneReport) > 0 {
+ fmt.Println("Deleted Volumes")
+ }
for _, r := range volumePruneReport {
if r.Err == nil {
fmt.Println(r.Id)
@@ -61,7 +70,10 @@ func PrintVolumePruneResults(volumePruneReport []*entities.VolumePruneReport) er
return errs.PrintErrors()
}
-func PrintImagePruneResults(imagePruneReport *entities.ImagePruneReport) error {
+func PrintImagePruneResults(imagePruneReport *entities.ImagePruneReport, heading bool) error {
+ if heading && (len(imagePruneReport.Report.Id) > 0 || len(imagePruneReport.Report.Err) > 0) {
+ fmt.Println("Deleted Images")
+ }
for _, i := range imagePruneReport.Report.Id {
fmt.Println(i)
}
diff --git a/cmd/podman/volumes/prune.go b/cmd/podman/volumes/prune.go
index 4c2136dcf..d1370120b 100644
--- a/cmd/podman/volumes/prune.go
+++ b/cmd/podman/volumes/prune.go
@@ -62,5 +62,5 @@ func prune(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- return utils.PrintVolumePruneResults(responses)
+ return utils.PrintVolumePruneResults(responses, false)
}