mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #16191 from odra/fix-16180_ancestor-filter-regex
adding regex support to the ancestor ps filter function
This commit is contained in:
@ -52,7 +52,7 @@ Valid filters are listed below:
|
|||||||
| label | [Key] or [Key=Value] Label assigned to a container |
|
| label | [Key] or [Key=Value] Label assigned to a container |
|
||||||
| exited | [Int] Container's exit code |
|
| exited | [Int] Container's exit code |
|
||||||
| status | [Status] Container's status: 'created', 'exited', 'paused', 'running', 'unknown' |
|
| status | [Status] Container's status: 'created', 'exited', 'paused', 'running', 'unknown' |
|
||||||
| ancestor | [ImageName] Image or descendant used to create container |
|
| ancestor | [ImageName] Image or descendant used to create container (accepts regex) |
|
||||||
| before | [ID] or [Name] Containers created before this container |
|
| before | [ID] or [Name] Containers created before this container |
|
||||||
| since | [ID] or [Name] Containers created since this container |
|
| since | [ID] or [Name] Containers created since this container |
|
||||||
| volume | [VolumeName] or [MountpointDestination] Volume mounted in container |
|
| volume | [VolumeName] or [MountpointDestination] Volume mounted in container |
|
||||||
|
@ -96,8 +96,8 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rootfsImageID == filterValue) ||
|
if (rootfsImageID == filterValue) ||
|
||||||
(rootfsImageName == filterValue) ||
|
util.StringMatchRegexSlice(rootfsImageName, filterValues) ||
|
||||||
(imageNameWithoutTag == filterValue && imageTag == "latest") {
|
(util.StringMatchRegexSlice(imageNameWithoutTag, filterValues) && imageTag == "latest") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,10 +313,22 @@ var _ = Describe("Podman ps", func() {
|
|||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.OutputToString()).To(Equal(cid))
|
Expect(result.OutputToString()).To(Equal(cid))
|
||||||
|
|
||||||
// Query by truncated image name should not match ( should return empty output )
|
// Query by truncated image name should match (regexp match)
|
||||||
result = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=quay.io/libpod/alpi"})
|
result = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=quay.io/libpod/alpi"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
|
Expect(result.OutputToString()).To(Equal(cid))
|
||||||
|
|
||||||
|
// Query using regex by truncated image name should match (regexp match)
|
||||||
|
result = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=^(quay.io|docker.io)/libpod/alpine:[a-zA-Z]+"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(Exit(0))
|
||||||
|
Expect(result.OutputToString()).To(Equal(cid))
|
||||||
|
|
||||||
|
// Query for an non-existing image using regex should not match anything
|
||||||
|
result = podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "-a", "--filter", "ancestor=^quai.io/libpod/alpi"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result).Should(Exit(0))
|
||||||
Expect(result.OutputToString()).To(Equal(""))
|
Expect(result.OutputToString()).To(Equal(""))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user