mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-24 08:01:03 +00:00
sort images by name
This commit is contained in:
parent
1924dd2bdb
commit
56b3196ef9
1 changed files with 15 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
|
|
@ -110,8 +111,6 @@ func (c *DockerCommand) RefreshImages() ([]*Image, error) {
|
||||||
ownImages := make([]*Image, len(images))
|
ownImages := make([]*Image, len(images))
|
||||||
|
|
||||||
for i, image := range images {
|
for i, image := range images {
|
||||||
// func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]image.HistoryResponseItem, error)
|
|
||||||
|
|
||||||
firstTag := ""
|
firstTag := ""
|
||||||
tags := image.RepoTags
|
tags := image.RepoTags
|
||||||
if len(tags) > 0 {
|
if len(tags) > 0 {
|
||||||
|
|
@ -138,6 +137,20 @@ func (c *DockerCommand) RefreshImages() ([]*Image, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noneLabel := "<none>"
|
||||||
|
|
||||||
|
sort.Slice(ownImages, func(i, j int) bool {
|
||||||
|
if ownImages[i].Name == noneLabel && ownImages[j].Name != noneLabel {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if ownImages[i].Name != noneLabel && ownImages[j].Name == noneLabel {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return ownImages[i].Name < ownImages[j].Name
|
||||||
|
})
|
||||||
|
|
||||||
return ownImages, nil
|
return ownImages, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue