diff options
author | Boaz Shuster <boaz.shuster.github@gmail.com> | 2021-04-20 16:17:16 +0300 |
---|---|---|
committer | Boaz Shuster <boaz.shuster.github@gmail.com> | 2021-05-06 14:35:15 +0300 |
commit | efdc7d84652bbdbf398c88d0287b0740f040a588 (patch) | |
tree | 25bc0f45eabf10fa80ff08ba49b73e2e04c6c395 /pkg/domain/infra/abi | |
parent | 0b05ba808d5e2fc75ce10b23405bd5c05da2c331 (diff) | |
download | podman-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 'pkg/domain/infra/abi')
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index ef3ccab0c..d0a2b1bae 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -694,7 +694,33 @@ func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrID s func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) { reports := []*entities.ContainerStartReport{} var exitCode = define.ExecErrorCodeGeneric - ctrs, rawInputs, err := getContainersAndInputByContext(options.All, options.Latest, namesOrIds, ic.Libpod) + containersNamesOrIds := namesOrIds + if len(options.Filters) > 0 { + filterFuncs := make([]libpod.ContainerFilter, 0, len(options.Filters)) + if len(options.Filters) > 0 { + for k, v := range options.Filters { + generatedFunc, err := dfilters.GenerateContainerFilterFuncs(k, v, ic.Libpod) + if err != nil { + return nil, err + } + filterFuncs = append(filterFuncs, generatedFunc) + } + } + candidates, err := ic.Libpod.GetContainers(filterFuncs...) + if err != nil { + return nil, err + } + containersNamesOrIds = []string{} + for _, candidate := range candidates { + for _, nameOrID := range namesOrIds { + if nameOrID == candidate.ID() || nameOrID == candidate.Name() { + containersNamesOrIds = append(containersNamesOrIds, nameOrID) + } + } + } + } + + ctrs, rawInputs, err := getContainersAndInputByContext(options.All, options.Latest, containersNamesOrIds, ic.Libpod) if err != nil { return nil, err } |