func CleanUp(do *definitions.Do) error { log.Info("Cleaning up") do.Force = true if do.Chain.ChainType == "throwaway" { log.WithField("=>", do.Chain.Name).Debug("Destroying throwaway chain") doRm := definitions.NowDo() doRm.Operations = do.Operations doRm.Name = do.Chain.Name doRm.Rm = true doRm.RmD = true doRm.Volumes = true KillChain(doRm) latentDir := filepath.Join(DataContainersPath, do.Chain.Name) latentFile := filepath.Join(ChainsPath, do.Chain.Name+".toml") if doRm.Name == "default" { log.WithField("dir", latentDir).Debug("Removing latent dir") os.RemoveAll(latentDir) } else { log.WithFields(log.Fields{ "dir": latentDir, "file": latentFile, }).Debug("Removing latent dir and file") os.RemoveAll(latentDir) os.Remove(latentFile) } } else { log.Debug("No throwaway chain to destroy") } if do.RmD { log.WithField("dir", filepath.Join(DataContainersPath, do.Service.Name)).Debug("Removing data dir on host") os.RemoveAll(filepath.Join(DataContainersPath, do.Service.Name)) } if do.Rm { log.WithField("=>", do.Operations.SrvContainerName).Debug("Removing tmp service container") perform.DockerRemove(do.Service, do.Operations, true, true, false) } return nil }
func CleanUp(do *definitions.Do) error { logger.Infof("Commensing CleanUp.\n") do.Force = true if do.Chain.ChainType == "throwaway" { logger.Debugf("Destroying Throwaway Chain =>\t%s\n", do.Chain.Name) doRm := definitions.NowDo() doRm.Operations = do.Operations doRm.Name = do.Chain.Name doRm.Rm = true doRm.RmD = true doRm.Volumes = true KillChain(doRm) if doRm.Name == "default" { logger.Debugf("Removing latent files/dirs =>\t%s\n", path.Join(DataContainersPath, do.Chain.Name)) os.RemoveAll(path.Join(DataContainersPath, do.Chain.Name)) } else { logger.Debugf("Removing latent files/dirs =>\t%s:%s\n", path.Join(DataContainersPath, do.Chain.Name), path.Join(ChainsPath, do.Chain.Name+".toml")) os.RemoveAll(path.Join(DataContainersPath, do.Chain.Name)) os.Remove(path.Join(ChainsPath, do.Chain.Name+".toml")) } } else { logger.Debugf("No Throwaway Chain to destroy.\n") } if do.RmD { logger.Debugf("Removing data dir on host =>\t%s\n", path.Join(DataContainersPath, do.Service.Name)) os.RemoveAll(path.Join(DataContainersPath, do.Service.Name)) } if do.Rm { logger.Debugf("Removing tmp srv contnr =>\t%s\n", do.Operations.SrvContainerName) perform.DockerRemove(do.Service, do.Operations, true, true) } return nil }