Skip to content

Commit

Permalink
fix: Resolve no clean images detected issue; Remove extra blank image…
Browse files Browse the repository at this point in the history
… name (#1055)

Signed-off-by: Akash Nayak <[email protected]>
  • Loading branch information
Akash-Nayak authored Jul 4, 2023
1 parent ed1eb73 commit a49a808
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion collector/imagescollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,20 @@ func getAllImageNames() ([]string, error) {
logrus.Warnf("Error while running docker image list : %s", err)
return nil, err
}
images := strings.Split(string(outputStr), "\n")
if len(outputStr) == 0 {
return []string{}, err
}
cleanimages := []string{}
images := strings.Split(strings.TrimSpace(string(outputStr)), "\n")
for _, image := range images {
if strings.HasPrefix(image, "<none>") || strings.HasSuffix(image, "<none>") {
logrus.Debugf("Ignore image with <none> : %s", image)
continue
} else {
cleanimages = append(cleanimages, image)
}
}
logrus.Debugf("clean images : %s", cleanimages)
return cleanimages, err
}

Expand Down

0 comments on commit a49a808

Please sign in to comment.