| 413 | } |
| 414 | |
| 415 | func (c *LocalCluster) Cleanup(verbose bool) { |
| 416 | if c == nil { |
| 417 | return |
| 418 | } |
| 419 | |
| 420 | if verbose { |
| 421 | if err := c.printAllLogs(); err != nil { |
| 422 | log.Printf("[WARNING] error printing container logs: %v", err) |
| 423 | } |
| 424 | if err := c.printInspectContainers(); err != nil { |
| 425 | log.Printf("[WARNING] error printing inspect container output: %v", err) |
| 426 | } |
| 427 | if err := c.printPortMappings(); err != nil { |
| 428 | log.Printf("[WARNING] error printing port mappings: %v", err) |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | log.Printf("[INFO] cleaning up cluster with prefix [%v]", c.conf.prefix) |
| 433 | if err := c.destroyContainers(); err != nil { |
| 434 | log.Printf("[WARNING] error removing container: %v", err) |
| 435 | } |
| 436 | |
| 437 | ctx, cancel := context.WithTimeout(context.Background(), requestTimeout) |
| 438 | defer cancel() |
| 439 | for _, vol := range c.conf.volumes { |
| 440 | if err := c.dcli.VolumeRemove(ctx, vol, true); err != nil { |
| 441 | log.Printf("[WARNING] error removing volume [%v]: %v", vol, err) |
| 442 | } |
| 443 | } |
| 444 | if c.net.id != "" { |
| 445 | if err := c.dcli.NetworkRemove(ctx, c.net.id); err != nil { |
| 446 | log.Printf("[WARNING] error removing network [%v]: %v", c.net.name, err) |
| 447 | } |
| 448 | } |
| 449 | if err := os.RemoveAll(c.tempBinDir); err != nil { |
| 450 | log.Printf("[WARNING] error while removing temp bin dir: %v", err) |
| 451 | } |
| 452 | if err := os.RemoveAll(c.tempSecretsDir); err != nil { |
| 453 | log.Printf("[WARNING] error while removing temp secrets dir: %v", err) |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | func (c *LocalCluster) cleanupDocker() error { |
| 458 | ctx, cancel := context.WithTimeout(context.Background(), requestTimeout) |