summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorflouthoc <flouthoc.git@gmail.com>2021-04-18 17:56:10 +0530
committerflouthoc <flouthoc.git@gmail.com>2021-04-25 13:49:40 +0530
commitb0ea40f551aa902f3bf0b590af24f911130328e9 (patch)
treec11b967a2eaa18ca3ee2c880393abb3d6bea7008 /pkg
parentba60821f0aadef99f200fa708b26fb9921ed7b70 (diff)
downloadpodman-b0ea40f551aa902f3bf0b590af24f911130328e9.tar.gz
podman-b0ea40f551aa902f3bf0b590af24f911130328e9.tar.bz2
podman-b0ea40f551aa902f3bf0b590af24f911130328e9.zip
Fix podman ps --filter ancestor to match exact ImageName/ImageID
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/filters/containers.go14
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
}
}