summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorBoaz Shuster <boaz.shuster.github@gmail.com>2021-04-20 16:17:16 +0300
committerBoaz Shuster <boaz.shuster.github@gmail.com>2021-05-06 14:35:15 +0300
commitefdc7d84652bbdbf398c88d0287b0740f040a588 (patch)
tree25bc0f45eabf10fa80ff08ba49b73e2e04c6c395 /cmd
parent0b05ba808d5e2fc75ce10b23405bd5c05da2c331 (diff)
downloadpodman-efdc7d84652bbdbf398c88d0287b0740f040a588.tar.gz
podman-efdc7d84652bbdbf398c88d0287b0740f040a588.tar.bz2
podman-efdc7d84652bbdbf398c88d0287b0740f040a588.zip
Add restart-policy to container filters & --filter to podman start
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/start.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/cmd/podman/containers/start.go b/cmd/podman/containers/start.go
index 8d62dc12f..dcd1eca82 100644
--- a/cmd/podman/containers/start.go
+++ b/cmd/podman/containers/start.go
@@ -3,6 +3,7 @@ package containers
import (
"fmt"
"os"
+ "strings"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
@@ -42,7 +43,9 @@ var (
)
var (
- startOptions entities.ContainerStartOptions
+ startOptions = entities.ContainerStartOptions{
+ Filters: make(map[string][]string),
+ }
)
func startFlags(cmd *cobra.Command) {
@@ -56,6 +59,8 @@ func startFlags(cmd *cobra.Command) {
flags.BoolVarP(&startOptions.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.BoolVar(&startOptions.SigProxy, "sig-proxy", false, "Proxy received signals to the process (default true if attaching, false otherwise)")
+ flags.StringSliceVarP(&filters, "filter", "f", []string{}, "Filter output based on conditions given")
+ _ = cmd.RegisterFlagCompletionFunc("filter", common.AutocompletePsFilters)
flags.BoolVar(&startOptions.All, "all", false, "Start all containers regardless of their state or configuration")
@@ -116,7 +121,18 @@ func start(cmd *cobra.Command, args []string) error {
startOptions.Stdout = os.Stdout
}
- responses, err := registry.ContainerEngine().ContainerStart(registry.GetContext(), args, startOptions)
+ var containers []string = args
+ if len(filters) > 0 {
+ for _, f := range filters {
+ split := strings.SplitN(f, "=", 2)
+ if len(split) == 1 {
+ return errors.Errorf("invalid filter %q", f)
+ }
+ startOptions.Filters[split[0]] = append(startOptions.Filters[split[0]], split[1])
+ }
+ }
+
+ responses, err := registry.ContainerEngine().ContainerStart(registry.GetContext(), containers, startOptions)
if err != nil {
return err
}