fix keep image number
This commit is contained in:
parent
41641861b8
commit
77d234831e
7
main.go
7
main.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user