mirror of
https://github.com/vale981/agru
synced 2025-03-05 17:51:42 -05:00
add cleanup
This commit is contained in:
parent
1458a600ae
commit
9f064bc553
1 changed files with 8 additions and 1 deletions
9
roles.go
9
roles.go
|
@ -49,18 +49,25 @@ func getNewVersion(src, version string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// cleanupRole removes all temporary dirs and files created during role installation
|
||||
func cleanupRole(tmpdir, tmpfile string) {
|
||||
os.RemoveAll(tmpdir) //nolint:errcheck // nothing can be done about it
|
||||
os.Remove(tmpfile) //nolint:errcheck // nothing can be done about it
|
||||
}
|
||||
|
||||
// installRole writes specific role version to the target roles dir
|
||||
func installRole(entry RequirementsEntry) {
|
||||
name := entry.GetName()
|
||||
log.Println("Installing", name, entry.Version)
|
||||
|
||||
repo := strings.Replace(entry.Src, "git+", "", 1)
|
||||
tmpdir, err := os.MkdirTemp("", "")
|
||||
tmpdir, err := os.MkdirTemp("", "agru-"+name+"-*")
|
||||
if err != nil {
|
||||
log.Println("ERROR: cannot create tmp dir:", err)
|
||||
return
|
||||
}
|
||||
tmpfile := tmpdir + ".tar"
|
||||
defer cleanupRole(tmpdir, tmpfile)
|
||||
|
||||
// clone repo
|
||||
var clone strings.Builder
|
||||
|
|
Loading…
Add table
Reference in a new issue