forked from moby/docker-ci-zap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zap.go
46 lines (42 loc) · 817 Bytes
/
zap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// +build windows
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/Microsoft/hcsshim"
)
func folderexists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
}
return true
}
func main() {
var folder string
flag.StringVar(&folder, "folder", "", "Folder to zap.")
flag.Parse()
if folder == "" {
fmt.Println("Error: folder must be supplied")
return
}
if folderexists(folder) {
location, foldername := filepath.Split(folder)
info := hcsshim.DriverInfo{
HomeDir: location,
Flavour: 0,
}
if err := hcsshim.DestroyLayer(info, foldername); err != nil {
fmt.Println("ERROR: ", err)
} else {
fmt.Println("INFO: Zapped successfully")
}
} else {
fmt.Println("ERROR: Folder does not exist")
}
}