diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-01-20 17:58:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 17:58:11 -0500 |
commit | 14443ccdfc19a7d719c63937ce76bfddf01f88e2 (patch) | |
tree | 3b3270237f9d3837668733e7364feb029037d437 /cmd/podman | |
parent | fe4f9ba303affde0b838e19c862b45206ae2feed (diff) | |
parent | e7df73efadd36e2489954ee9a766a3fbfe4eafeb (diff) | |
download | podman-14443ccdfc19a7d719c63937ce76bfddf01f88e2.tar.gz podman-14443ccdfc19a7d719c63937ce76bfddf01f88e2.tar.bz2 podman-14443ccdfc19a7d719c63937ce76bfddf01f88e2.zip |
Merge pull request #9014 from rhatdan/rm
Fix handling of container remove
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/containers/rm.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cmd/podman/containers/rm.go b/cmd/podman/containers/rm.go index ee9dc4c78..ea616b6e5 100644 --- a/cmd/podman/containers/rm.go +++ b/cmd/podman/containers/rm.go @@ -3,6 +3,7 @@ package containers import ( "context" "fmt" + "io/ioutil" "strings" "github.com/containers/common/pkg/completion" @@ -54,6 +55,7 @@ var ( var ( rmOptions = entities.RmOptions{} + cidFiles = []string{} ) func rmFlags(cmd *cobra.Command) { @@ -65,7 +67,7 @@ func rmFlags(cmd *cobra.Command) { flags.BoolVarP(&rmOptions.Volumes, "volumes", "v", false, "Remove anonymous volumes associated with the container") cidfileFlagName := "cidfile" - flags.StringArrayVarP(&rmOptions.CIDFiles, cidfileFlagName, "", nil, "Read the container ID from the file") + flags.StringArrayVar(&cidFiles, cidfileFlagName, nil, "Read the container ID from the file") _ = cmd.RegisterFlagCompletionFunc(cidfileFlagName, completion.AutocompleteDefault) if !registry.IsRemote() { @@ -92,7 +94,16 @@ func init() { validate.AddLatestFlag(containerRmCommand, &rmOptions.Latest) } -func rm(_ *cobra.Command, args []string) error { +func rm(cmd *cobra.Command, args []string) error { + for _, cidFile := range cidFiles { + content, err := ioutil.ReadFile(string(cidFile)) + if err != nil { + return errors.Wrap(err, "error reading CIDFile") + } + id := strings.Split(string(content), "\n")[0] + args = append(args, id) + } + return removeContainers(args, rmOptions, true) } |