Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builder: Add support for builder prune #11932

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cmd/podman/images/buildx.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ var (
// If we are adding new buildx features, we will add them by default
// to podman build.
buildxCmd = &cobra.Command{
Use: "buildx",
Short: "Build images",
Long: "Build images",
RunE: validate.SubCommandExists,
Hidden: true,
Use: "buildx",
Aliases: []string{"builder"},
Short: "Build images",
Long: "Build images",
RunE: validate.SubCommandExists,
Hidden: true,
}
)

Expand Down
5 changes: 5 additions & 0 deletions cmd/podman/images/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

})

})