fix keep image number

This commit is contained in:
Jay 2019-03-07 17:15:06 +08:00
parent 41641861b8
commit 77d234831e

View File

@ -114,6 +114,7 @@ func main() {
}
iarr := ImageArr{}
keepNum := runFlag.KeepNum
for _, v := range imgs.ImageDetails {
excludeFlag := false
if len(runFlag.ExcludeTag) > 0 {
@ -123,6 +124,7 @@ func main() {
if *v2 == e {
f = true
excludeFlag = true
keepNum--
break
}
}
@ -135,8 +137,11 @@ func main() {
iarr = append(iarr, v)
}
}
if keepNum < 0 {
keepNum = 0
}
sort.Stable(iarr)
iarr = iarr[runFlag.KeepNum:]
iarr = iarr[keepNum:]
if len(iarr) == 0 {
fmt.Println("no delete image")
return