summaryrefslogtreecommitdiff
path: root/cmd/podman/networks
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-09-30 14:43:39 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-10-04 07:07:56 -0400
commit21c9dc3c406bb486c44c4a27e5b0497bab1cd40d (patch)
tree56793ffd885f835fa54013e9914844ff9ba20d92 /cmd/podman/networks
parent36821d302e3787a42d6eefdbd0bdbb6d9da261fb (diff)
downloadpodman-21c9dc3c406bb486c44c4a27e5b0497bab1cd40d.tar.gz
podman-21c9dc3c406bb486c44c4a27e5b0497bab1cd40d.tar.bz2
podman-21c9dc3c406bb486c44c4a27e5b0497bab1cd40d.zip
Add --time out for podman * rm -f commands
Add --time flag to podman container rm Add --time flag to podman pod rm Add --time flag to podman volume rm Add --time flag to podman network rm Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/networks')
-rw-r--r--cmd/podman/networks/network.go2
-rw-r--r--cmd/podman/networks/rm.go11
2 files changed, 13 insertions, 0 deletions
diff --git a/cmd/podman/networks/network.go b/cmd/podman/networks/network.go
index ec045e3cf..1070e7e82 100644
--- a/cmd/podman/networks/network.go
+++ b/cmd/podman/networks/network.go
@@ -3,6 +3,7 @@ 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/util"
"github.com/spf13/cobra"
)
@@ -17,6 +18,7 @@ var (
Long: "Manage networks",
RunE: validate.SubCommandExists,
}
+ containerConfig = util.DefaultContainerConfig()
)
func init() {
diff --git a/cmd/podman/networks/rm.go b/cmd/podman/networks/rm.go
index 14f9869e4..5efd02933 100644
--- a/cmd/podman/networks/rm.go
+++ b/cmd/podman/networks/rm.go
@@ -4,6 +4,7 @@ import (
"fmt"
"strings"
+ "github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/utils"
@@ -26,6 +27,7 @@ var (
Args: cobra.MinimumNArgs(1),
ValidArgsFunction: common.AutocompleteNetworks,
}
+ stopTimeout uint
)
var (
@@ -34,6 +36,9 @@ var (
func networkRmFlags(flags *pflag.FlagSet) {
flags.BoolVarP(&networkRmOptions.Force, "force", "f", false, "remove any containers using network")
+ timeFlagName := "time"
+ flags.UintVarP(&stopTimeout, timeFlagName, "t", containerConfig.Engine.StopTimeout, "Seconds to wait for running containers to stop before killing the container")
+ _ = networkrmCommand.RegisterFlagCompletionFunc(timeFlagName, completion.AutocompleteNone)
}
func init() {
@@ -50,6 +55,12 @@ func networkRm(cmd *cobra.Command, args []string) error {
errs utils.OutputErrors
)
+ if cmd.Flag("time").Changed {
+ if !networkRmOptions.Force {
+ return errors.New("--force option must be specified to use the --time option")
+ }
+ networkRmOptions.Timeout = &stopTimeout
+ }
responses, err := registry.ContainerEngine().NetworkRm(registry.Context(), args, networkRmOptions)
if err != nil {
setExitCode(err)