summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/tunnel/helpers.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-02-16 05:17:52 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2021-02-16 06:26:51 -0500
commit4a9bd7a18f2db7db103a94287ef34cbd1be1626b (patch)
treebb55c84c2e37c1fdb9b03c56d38078020ab78f58 /pkg/domain/infra/tunnel/helpers.go
parentdf8ba7f4a92750bfb173b5486a663d1735d70b2d (diff)
downloadpodman-4a9bd7a18f2db7db103a94287ef34cbd1be1626b.tar.gz
podman-4a9bd7a18f2db7db103a94287ef34cbd1be1626b.tar.bz2
podman-4a9bd7a18f2db7db103a94287ef34cbd1be1626b.zip
When stopping a container, print rawInput
When we stop a container we are printing the full id, this does not match Docker behaviour or the start behavior. We should be printing the users rawInput when we successfully stop the container. Fixes: https://github.com/containers/podman/issues/9386 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/domain/infra/tunnel/helpers.go')
-rw-r--r--pkg/domain/infra/tunnel/helpers.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/pkg/domain/infra/tunnel/helpers.go b/pkg/domain/infra/tunnel/helpers.go
index e40e27596..5fa70bffa 100644
--- a/pkg/domain/infra/tunnel/helpers.go
+++ b/pkg/domain/infra/tunnel/helpers.go
@@ -14,16 +14,26 @@ import (
// FIXME: the `ignore` parameter is very likely wrong here as it should rather
// be used on *errors* from operations such as remove.
func getContainersByContext(contextWithConnection context.Context, all, ignore bool, namesOrIDs []string) ([]entities.ListContainer, error) {
+ ctrs, _, err := getContainersAndInputByContext(contextWithConnection, all, ignore, namesOrIDs)
+ return ctrs, err
+}
+
+func getContainersAndInputByContext(contextWithConnection context.Context, all, ignore bool, namesOrIDs []string) ([]entities.ListContainer, []string, error) {
if all && len(namesOrIDs) > 0 {
- return nil, errors.New("cannot lookup containers and all")
+ return nil, nil, errors.New("cannot lookup containers and all")
}
options := new(containers.ListOptions).WithAll(true).WithSync(true)
allContainers, err := containers.List(contextWithConnection, options)
if err != nil {
- return nil, err
+ return nil, nil, err
}
+ rawInputs := []string{}
if all {
- return allContainers, err
+ for i := range allContainers {
+ rawInputs = append(rawInputs, allContainers[i].ID)
+ }
+
+ return allContainers, rawInputs, err
}
// Note: it would be nicer if the lists endpoint would support that as
@@ -42,7 +52,7 @@ func getContainersByContext(contextWithConnection context.Context, all, ignore b
if ignore && errorhandling.Contains(err, define.ErrNoSuchCtr) {
continue
}
- return nil, err
+ return nil, nil, err
}
// Now we can do a full match of the ID to find the right
@@ -52,16 +62,17 @@ func getContainersByContext(contextWithConnection context.Context, all, ignore b
for _, ctr := range allContainers {
if ctr.ID == inspectData.ID {
filtered = append(filtered, ctr)
+ rawInputs = append(rawInputs, nameOrID)
found = true
break
}
}
if !found && !ignore {
- return nil, errors.Wrapf(define.ErrNoSuchCtr, "unable to find container %q", nameOrID)
+ return nil, nil, errors.Wrapf(define.ErrNoSuchCtr, "unable to find container %q", nameOrID)
}
}
- return filtered, nil
+ return filtered, rawInputs, nil
}
func getPodsByContext(contextWithConnection context.Context, all bool, namesOrIDs []string) ([]*entities.ListPodsReport, error) {