mirror of https://github.com/containers/podman.git
builder: Add support for builder prune
Docker has support for docker builder prune and docker builder build This patch will add a hidden command to support scripts using this syntax. We don't want to encourage this deviation. Add podman build prune to implement docker builder prune functionality. Co-authored-by: Daniel J Walsh <dwalsh@redhat.com> Signed-off-by: Aditya Rajan <arajan@redhat.com>
This commit is contained in:
parent
2fcec59445
commit
ab8fb3876d
|
@ -15,6 +15,7 @@ var (
|
||||||
// to podman build.
|
// to podman build.
|
||||||
buildxCmd = &cobra.Command{
|
buildxCmd = &cobra.Command{
|
||||||
Use: "buildx",
|
Use: "buildx",
|
||||||
|
Aliases: []string{"builder"},
|
||||||
Short: "Build images",
|
Short: "Build images",
|
||||||
Long: "Build images",
|
Long: "Build images",
|
||||||
RunE: validate.SubCommandExists,
|
RunE: validate.SubCommandExists,
|
||||||
|
|
|
@ -34,6 +34,11 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
registry.Commands = append(registry.Commands, registry.CliCommand{
|
||||||
|
Command: pruneCmd,
|
||||||
|
Parent: buildxCmd,
|
||||||
|
})
|
||||||
|
|
||||||
registry.Commands = append(registry.Commands, registry.CliCommand{
|
registry.Commands = append(registry.Commands, registry.CliCommand{
|
||||||
Command: pruneCmd,
|
Command: pruneCmd,
|
||||||
Parent: imageCmd,
|
Parent: imageCmd,
|
||||||
|
|
|
@ -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))
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue