summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/tunnel/containers.go
diff options
context:
space:
mode:
authorToshiki Sonoda <sonoda.toshiki@fujitsu.com>2022-08-23 09:58:34 +0900
committerToshiki Sonoda <sonoda.toshiki@fujitsu.com>2022-08-23 09:58:34 +0900
commit716ac1c866787d7d6b1ee8b800da527fd5b980d0 (patch)
tree843e45cf642c1a353bd6717f5595d35577cbe0de /pkg/domain/infra/tunnel/containers.go
parent51d4b88ce976708de88ce041a03d6d65dd4c8d0e (diff)
downloadpodman-716ac1c866787d7d6b1ee8b800da527fd5b980d0.tar.gz
podman-716ac1c866787d7d6b1ee8b800da527fd5b980d0.tar.bz2
podman-716ac1c866787d7d6b1ee8b800da527fd5b980d0.zip
Refactor: About the RawInput process
Refactor the RawInput process of the `rm` and `start` subcommands, like the other subcommands such as `restart, stop, etc`. [NO NEW TESTS NEEDED] Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
Diffstat (limited to 'pkg/domain/infra/tunnel/containers.go')
-rw-r--r--pkg/domain/infra/tunnel/containers.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 046509140..023bee430 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -672,10 +672,16 @@ func logIfRmError(id string, err error, reports []*reports.RmReport) {
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
reports := []*entities.ContainerStartReport{}
var exitCode = define.ExecErrorCodeGeneric
- ctrs, namesOrIds, err := getContainersAndInputByContext(ic.ClientCtx, options.All, false, namesOrIds, options.Filters)
+ ctrs, rawInputs, err := getContainersAndInputByContext(ic.ClientCtx, options.All, false, namesOrIds, options.Filters)
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]
+ }
+ }
removeOptions := new(containers.RemoveOptions).WithVolumes(true).WithForce(false)
removeContainer := func(id string) {
reports, err := containers.Remove(ic.ClientCtx, id, removeOptions)
@@ -683,15 +689,11 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
}
// There can only be one container if attach was used
- for i, ctr := range ctrs {
+ for _, ctr := range ctrs {
name := ctr.ID
- rawInput := ctr.ID
- if !options.All {
- rawInput = namesOrIds[i]
- }
report := entities.ContainerStartReport{
Id: name,
- RawInput: rawInput,
+ RawInput: idToRawInput[name],
ExitCode: exitCode,
}
ctrRunning := ctr.State == define.ContainerStateRunning.String()