diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-08-05 06:43:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 06:43:56 +0000 |
commit | 49ee311950470ef910b244b2bca78b9c8c645422 (patch) | |
tree | 5d29573585027c7cd3edfc0fd39c064cf564b96b /cmd/podman | |
parent | b0ef621ebf196fd61189aebff3161927f0049c52 (diff) | |
parent | 9964366f69a1fbaa709e45c3d3ebcada283a76b7 (diff) | |
download | podman-49ee311950470ef910b244b2bca78b9c8c645422.tar.gz podman-49ee311950470ef910b244b2bca78b9c8c645422.tar.bz2 podman-49ee311950470ef910b244b2bca78b9c8c645422.zip |
Merge pull request #15092 from karthikelango137/startFilter
start --filter flag changes
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/containers/start.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/cmd/podman/containers/start.go b/cmd/podman/containers/start.go index cd4fa17b8..fc3488e0c 100644 --- a/cmd/podman/containers/start.go +++ b/cmd/podman/containers/start.go @@ -59,8 +59,10 @@ 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) + + filterFlagName := "filter" + flags.StringSliceVarP(&filters, filterFlagName, "f", []string{}, "Filter output based on conditions given") + _ = cmd.RegisterFlagCompletionFunc(filterFlagName, common.AutocompletePsFilters) flags.BoolVar(&startOptions.All, "all", false, "Start all containers regardless of their state or configuration") @@ -84,7 +86,7 @@ func init() { } func validateStart(cmd *cobra.Command, args []string) error { - if len(args) == 0 && !startOptions.Latest && !startOptions.All { + if len(args) == 0 && !startOptions.Latest && !startOptions.All && len(filters) < 1 { return errors.New("start requires at least one argument") } if startOptions.All && startOptions.Latest { @@ -123,14 +125,12 @@ func start(cmd *cobra.Command, args []string) error { } containers := args - if len(filters) > 0 { - for _, f := range filters { - split := strings.SplitN(f, "=", 2) - if len(split) == 1 { - return fmt.Errorf("invalid filter %q", f) - } - startOptions.Filters[split[0]] = append(startOptions.Filters[split[0]], split[1]) + for _, f := range filters { + split := strings.SplitN(f, "=", 2) + if len(split) < 2 { + return fmt.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) |