Merge pull request #11932 from flouthoc/build-prune

builder: Add support for builder prune
This commit is contained in:
OpenShift Merge Robot
2021-10-12 19:32:10 +02:00
committed by GitHub
3 changed files with 32 additions and 5 deletions

View File

@ -15,6 +15,7 @@ var (
// to podman build.
buildxCmd = &cobra.Command{
Use: "buildx",
Aliases: []string{"builder"},
Short: "Build images",
Long: "Build images",
RunE: validate.SubCommandExists,

View File

@ -34,6 +34,11 @@ var (
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: pruneCmd,
Parent: buildxCmd,
})
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: pruneCmd,
Parent: imageCmd,

View File

@ -446,4 +446,25 @@ RUN > file2
})
It("podman builder prune", func() {
dockerfile := `FROM quay.io/libpod/alpine:latest
RUN > file
`
dockerfile2 := `FROM quay.io/libpod/alpine:latest
RUN > file2
`
podmanTest.BuildImageWithLabel(dockerfile, "foobar.com/workdir:latest", "false", "abc")
podmanTest.BuildImageWithLabel(dockerfile2, "foobar.com/workdir:latest", "false", "xyz")
// --force used to to avoid y/n question
result := podmanTest.Podman([]string{"builder", "prune", "--filter", "label=abc", "--force"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
Expect(len(result.OutputToStringArray())).To(Equal(1))
//check if really abc is removed
result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
Expect(len(result.OutputToStringArray())).To(Equal(0))
})
})