summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-01-20 17:13:54 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2021-01-29 14:04:44 -0500
commit073f76c1327d296360caa04ef7d751dd00ef5a53 (patch)
treea67939035cf627e6548f70c6643a520dc8241817 /cmd
parent8f3bcf62474bbfba26982bae88febecd4fa630c2 (diff)
downloadpodman-073f76c1327d296360caa04ef7d751dd00ef5a53.tar.gz
podman-073f76c1327d296360caa04ef7d751dd00ef5a53.tar.bz2
podman-073f76c1327d296360caa04ef7d751dd00ef5a53.zip
Switch podman stop/kill/wait handlers to use abi
Change API Handlers to use the same functions that the local podman uses. At the same time: implement remote API for --all and --ignore flags for podman stop implement remote API for --all flags for podman stop Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/kill.go15
-rw-r--r--cmd/podman/containers/stop.go14
-rw-r--r--cmd/podman/containers/wait.go2
3 files changed, 27 insertions, 4 deletions
diff --git a/cmd/podman/containers/kill.go b/cmd/podman/containers/kill.go
index 28040e08a..36e3e5f59 100644
--- a/cmd/podman/containers/kill.go
+++ b/cmd/podman/containers/kill.go
@@ -2,8 +2,9 @@ package containers
import (
"context"
- "errors"
"fmt"
+ "io/ioutil"
+ "strings"
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v2/cmd/podman/common"
@@ -12,6 +13,7 @@ import (
"github.com/containers/podman/v2/cmd/podman/validate"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/signal"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -59,7 +61,7 @@ func killFlags(cmd *cobra.Command) {
flags.StringVarP(&killOptions.Signal, signalFlagName, "s", "KILL", "Signal to send to the container")
_ = cmd.RegisterFlagCompletionFunc(signalFlagName, common.AutocompleteStopSignal)
cidfileFlagName := "cidfile"
- flags.StringArrayVar(&killOptions.CIDFiles, cidfileFlagName, []string{}, "Read the container ID from the file")
+ flags.StringArrayVar(&cidFiles, cidfileFlagName, []string{}, "Read the container ID from the file")
_ = cmd.RegisterFlagCompletionFunc(cidfileFlagName, completion.AutocompleteDefault)
}
@@ -94,6 +96,15 @@ func kill(_ *cobra.Command, args []string) error {
if sig < 1 || sig > 64 {
return errors.New("valid signals are 1 through 64")
}
+ 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)
+ }
+
responses, err := registry.ContainerEngine().ContainerKill(context.Background(), args, killOptions)
if err != nil {
return err
diff --git a/cmd/podman/containers/stop.go b/cmd/podman/containers/stop.go
index 3a4211357..7338c8d98 100644
--- a/cmd/podman/containers/stop.go
+++ b/cmd/podman/containers/stop.go
@@ -3,6 +3,8 @@ package containers
import (
"context"
"fmt"
+ "io/ioutil"
+ "strings"
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v2/cmd/podman/common"
@@ -10,6 +12,7 @@ import (
"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/pkg/errors"
"github.com/spf13/cobra"
)
@@ -58,7 +61,7 @@ func stopFlags(cmd *cobra.Command) {
flags.BoolVarP(&stopOptions.Ignore, "ignore", "i", false, "Ignore errors when a specified container is missing")
cidfileFlagName := "cidfile"
- flags.StringArrayVarP(&stopOptions.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)
timeFlagName := "time"
@@ -97,6 +100,15 @@ func stop(cmd *cobra.Command, args []string) error {
stopOptions.Timeout = &stopTimeout
}
+ 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)
+ }
+
responses, err := registry.ContainerEngine().ContainerStop(context.Background(), args, stopOptions)
if err != nil {
return err
diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go
index 2bbfbccc9..14d660678 100644
--- a/cmd/podman/containers/wait.go
+++ b/cmd/podman/containers/wait.go
@@ -50,7 +50,7 @@ func waitFlags(cmd *cobra.Command) {
flags := cmd.Flags()
intervalFlagName := "interval"
- flags.StringVarP(&waitInterval, intervalFlagName, "i", "250ns", "Time Interval to wait before polling for completion")
+ flags.StringVarP(&waitInterval, intervalFlagName, "i", "250ms", "Time Interval to wait before polling for completion")
_ = cmd.RegisterFlagCompletionFunc(intervalFlagName, completion.AutocompleteNone)
conditionFlagName := "condition"