diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-06 14:50:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-06 14:50:26 -0400 |
commit | 034470e5be8cfeef8ce0e0d2f47587a660682219 (patch) | |
tree | 74af195993a2fd2136c980b8035629fe4863051d /cmd | |
parent | 44184167e495a64f1a565a2bc2cccb6b5bc56eaa (diff) | |
parent | efdc7d84652bbdbf398c88d0287b0740f040a588 (diff) | |
download | podman-034470e5be8cfeef8ce0e0d2f47587a660682219.tar.gz podman-034470e5be8cfeef8ce0e0d2f47587a660682219.tar.bz2 podman-034470e5be8cfeef8ce0e0d2f47587a660682219.zip |
Merge pull request #9689 from boaz0/boaz-1
add restart-policy to container filters & --filter to podman start
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/containers/start.go | 20 |
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 } |