diff options
Diffstat (limited to 'pkg/domain/infra/tunnel/containers.go')
-rw-r--r-- | pkg/domain/infra/tunnel/containers.go | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go index e9c513f8e..a0f65f11f 100644 --- a/pkg/domain/infra/tunnel/containers.go +++ b/pkg/domain/infra/tunnel/containers.go @@ -12,15 +12,15 @@ import ( "github.com/containers/common/pkg/config" "github.com/containers/image/v5/docker/reference" - "github.com/containers/podman/v2/libpod/define" - "github.com/containers/podman/v2/libpod/events" - "github.com/containers/podman/v2/pkg/api/handlers" - "github.com/containers/podman/v2/pkg/bindings/containers" - "github.com/containers/podman/v2/pkg/domain/entities" - "github.com/containers/podman/v2/pkg/domain/entities/reports" - "github.com/containers/podman/v2/pkg/errorhandling" - "github.com/containers/podman/v2/pkg/specgen" - "github.com/containers/podman/v2/pkg/util" + "github.com/containers/podman/v3/libpod/define" + "github.com/containers/podman/v3/libpod/events" + "github.com/containers/podman/v3/pkg/api/handlers" + "github.com/containers/podman/v3/pkg/bindings/containers" + "github.com/containers/podman/v3/pkg/domain/entities" + "github.com/containers/podman/v3/pkg/domain/entities/reports" + "github.com/containers/podman/v3/pkg/errorhandling" + "github.com/containers/podman/v3/pkg/specgen" + "github.com/containers/podman/v3/pkg/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -82,16 +82,23 @@ func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []st func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, opts entities.StopOptions) ([]*entities.StopReport, error) { reports := []*entities.StopReport{} - ctrs, err := getContainersByContext(ic.ClientCtx, opts.All, opts.Ignore, namesOrIds) + ctrs, rawInputs, err := getContainersAndInputByContext(ic.ClientCtx, opts.All, opts.Ignore, namesOrIds) if err != nil { return nil, err } + ctrMap := map[string]string{} + for i := range ctrs { + ctrMap[ctrs[i].ID] = rawInputs[i] + } options := new(containers.StopOptions).WithIgnore(opts.Ignore) if to := opts.Timeout; to != nil { options.WithTimeout(*to) } for _, c := range ctrs { - report := entities.StopReport{Id: c.ID} + report := entities.StopReport{ + Id: c.ID, + RawInput: ctrMap[c.ID], + } if err = containers.Stop(ic.ClientCtx, c.ID, options); err != nil { // These first two are considered non-fatal under the right conditions if errors.Cause(err).Error() == define.ErrCtrStopped.Error() { @@ -117,16 +124,21 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin } func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []string, opts entities.KillOptions) ([]*entities.KillReport, error) { - ctrs, err := getContainersByContext(ic.ClientCtx, opts.All, false, namesOrIds) + ctrs, rawInputs, err := getContainersAndInputByContext(ic.ClientCtx, opts.All, false, namesOrIds) if err != nil { return nil, err } + ctrMap := map[string]string{} + for i := range ctrs { + ctrMap[ctrs[i].ID] = rawInputs[i] + } options := new(containers.KillOptions).WithSignal(opts.Signal) reports := make([]*entities.KillReport, 0, len(ctrs)) for _, c := range ctrs { reports = append(reports, &entities.KillReport{ - Id: c.ID, - Err: containers.Kill(ic.ClientCtx, c.ID, options), + Id: c.ID, + Err: containers.Kill(ic.ClientCtx, c.ID, options), + RawInput: ctrMap[c.ID], }) } return reports, nil @@ -290,7 +302,6 @@ func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds [ ctrs = append(ctrs, c) } } - } else { ctrs, err = getContainersByContext(ic.ClientCtx, false, false, namesOrIds) if err != nil { @@ -326,7 +337,6 @@ func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []st ctrs = append(ctrs, c) } } - } else { ctrs, err = getContainersByContext(ic.ClientCtx, false, false, namesOrIds) if err != nil { @@ -570,7 +580,6 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri } // Start the container if it's not running already. if !ctrRunning { - err = containers.Start(ic.ClientCtx, name, new(containers.StartOptions).WithDetachKeys(options.DetachKeys)) if err != nil { if ctr.AutoRemove { |