diff options
author | Toshiki Sonoda <sonoda.toshiki@fujitsu.com> | 2022-08-12 09:22:53 +0900 |
---|---|---|
committer | Toshiki Sonoda <sonoda.toshiki@fujitsu.com> | 2022-08-12 09:22:53 +0900 |
commit | 0dbbb1cb3f6ed2983105620bc49191e3b0436f37 (patch) | |
tree | 864cb7cf1adeeada7cb817e3e00c0f92b7fe995c /pkg/domain/infra/abi | |
parent | 0fc27ce9805ff1e8c4abd80bd711c60b4d75d3f3 (diff) | |
download | podman-0dbbb1cb3f6ed2983105620bc49191e3b0436f37.tar.gz podman-0dbbb1cb3f6ed2983105620bc49191e3b0436f37.tar.bz2 podman-0dbbb1cb3f6ed2983105620bc49191e3b0436f37.zip |
Add restart --cidfile, --filter
--cidfile : Read container ID from the specified file and restart the container.
--filter : restart the filtered container.
Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
Diffstat (limited to 'pkg/domain/infra/abi')
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 5b5bc665e..08d845d70 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -309,31 +309,42 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []string, options entities.RestartOptions) ([]*entities.RestartReport, error) { var ( - ctrs []*libpod.Container - err error + ctrs []*libpod.Container + err error + rawInputs = []string{} ) if options.Running { ctrs, err = ic.Libpod.GetRunningContainers() + for _, candidate := range ctrs { + rawInputs = append(rawInputs, candidate.ID()) + } + if err != nil { return nil, err } } else { - ctrs, err = getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod) + ctrs, rawInputs, err = getContainersAndInputByContext(options.All, options.Latest, namesOrIds, options.Filters, ic.Libpod) if err != nil { return nil, err } } - + idToRawInput := map[string]string{} + if len(rawInputs) == len(ctrs) { + for i := range ctrs { + idToRawInput[ctrs[i].ID()] = rawInputs[i] + } + } reports := make([]*entities.RestartReport, 0, len(ctrs)) - for _, con := range ctrs { - timeout := con.StopTimeout() + for _, c := range ctrs { + timeout := c.StopTimeout() if options.Timeout != nil { timeout = *options.Timeout } reports = append(reports, &entities.RestartReport{ - Id: con.ID(), - Err: con.RestartWithTimeout(ctx, timeout), + Id: c.ID(), + Err: c.RestartWithTimeout(ctx, timeout), + RawInput: idToRawInput[c.ID()], }) } return reports, nil |