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