From 9701f08184a8e6242a8d0e523d7a2e341c179961 Mon Sep 17 00:00:00 2001 From: Luther Date: Fri, 22 May 2020 13:15:19 -0700 Subject: [PATCH] adding ignore checks for prune and rmi --- docker.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docker.go b/docker.go index be23616..22aedcc 100644 --- a/docker.go +++ b/docker.go @@ -135,6 +135,10 @@ func (p Plugin) Exec() error { err := cmd.Run() if err != nil && isCommandPull(cmd.Args) { fmt.Printf("Could not pull cache-from image %s. Ignoring...\n", cmd.Args[2]) + } else if err != nil && isCommandPrune(cmd.Args) { + fmt.Printf("Could not prune system containers. Ignoring...\n") + } else if err != nil && isCommandRmi(cmd.Args) { + fmt.Printf("Could not remove image %s. Ignoring...\n", cmd.Args[2]) } else if err != nil { return err } @@ -341,10 +345,21 @@ func commandDaemon(daemon Daemon) *exec.Cmd { return exec.Command(dockerdExe, args...) } + +// helper to check if args match "docker prune" +func isCommandPrune(args []string) bool { + return len(args) > 2 && args[1] == "prune" +} + func commandPrune() *exec.Cmd { return exec.Command(dockerExe, "system", "prune", "-f") } +// helper to check if args match "docker rmi" +func isCommandRmi(args []string) bool { + return len(args) > 2 && args[1] == "rmi" +} + func commandRmi(tag string) *exec.Cmd { return exec.Command(dockerExe, "rmi", tag) }