diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-26 20:23:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 20:23:54 -0400 |
commit | 54344d3a6440f2e80b9eba5205e87b6b4261c02c (patch) | |
tree | 2d7181b0bc3af601920428b7227dd0499c0748df /pkg | |
parent | bdcfdadb2f41af203293a662c2b1bf5e5514586e (diff) | |
parent | b0ea40f551aa902f3bf0b590af24f911130328e9 (diff) | |
download | podman-54344d3a6440f2e80b9eba5205e87b6b4261c02c.tar.gz podman-54344d3a6440f2e80b9eba5205e87b6b4261c02c.tar.bz2 podman-54344d3a6440f2e80b9eba5205e87b6b4261c02c.zip |
Merge pull request #10074 from flouthoc/ancestor-truncate-bug
Fix podman ps --filter ancestor to match exact ImageName/ImageID
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/domain/filters/containers.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go index 45791cd84..9ac72e415 100644 --- a/pkg/domain/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -83,7 +83,19 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo return func(c *libpod.Container) bool { for _, filterValue := range filterValues { containerConfig := c.Config() - if strings.Contains(containerConfig.RootfsImageID, filterValue) || strings.Contains(containerConfig.RootfsImageName, filterValue) { + var imageTag string + var imageNameWithoutTag string + // Compare with ImageID, ImageName + // Will match ImageName if running image has tag latest for other tags exact complete filter must be given + imageNameSlice := strings.SplitN(containerConfig.RootfsImageName, ":", 2) + if len(imageNameSlice) == 2 { + imageNameWithoutTag = imageNameSlice[0] + imageTag = imageNameSlice[1] + } + + if (containerConfig.RootfsImageID == filterValue) || + (containerConfig.RootfsImageName == filterValue) || + (imageNameWithoutTag == filterValue && imageTag == "latest") { return true } } |