Skip to content

Commit fc3c003

Browse files
authored
1.5.5 (#22)
* Fixed image dangling logic and added InUse field to images * Bumped version to 1.5.5
1 parent bcc9db3 commit fc3c003

File tree

7 files changed

+18
-6
lines changed

7 files changed

+18
-6
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
branches: ["main"]
99

1010
env:
11-
VERSION: "1.5.4"
11+
VERSION: "1.5.5"
1212

1313
jobs:
1414
docker:

pkg/common/common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package common
22

3-
const Version = "1.5.4"
3+
const Version = "1.5.5"

pkg/dockerapi/image.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dockerapi
33
import (
44
"context"
55
"errors"
6+
"slices"
67
"sort"
78
"strings"
89

@@ -17,6 +18,11 @@ func ImageList(req *DockerImageList) (*DockerImageListResponse, error) {
1718
return nil, err
1819
}
1920

21+
dcontainers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{All: req.All})
22+
if err != nil {
23+
return nil, err
24+
}
25+
2026
dimages, err := cli.ImageList(context.Background(), types.ImageListOptions{All: req.All})
2127
if err != nil {
2228
return nil, err
@@ -26,9 +32,10 @@ func ImageList(req *DockerImageList) (*DockerImageListResponse, error) {
2632
for i, item := range dimages {
2733
name := "<none>"
2834
tag := "<none>"
29-
dangling := len(item.RepoTags) == 0
35+
inUse := slices.ContainsFunc(dcontainers, func(c types.Container) bool { return c.ImageID == item.ID })
36+
untagged := len(item.RepoTags) == 0
3037

31-
if dangling {
38+
if untagged {
3239
if len(item.RepoDigests) >= 1 {
3340
name = strings.Split(item.RepoDigests[0], "@")[0]
3441
}
@@ -45,8 +52,9 @@ func ImageList(req *DockerImageList) (*DockerImageListResponse, error) {
4552
Name: name,
4653
Tag: tag,
4754
Size: item.Size,
48-
Dangling: dangling,
55+
Dangling: untagged && !inUse,
4956
Created: item.Created,
57+
InUse: inUse,
5058
}
5159
}
5260

pkg/dockerapi/models.go

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type Image struct {
6363
Size int64 `json:"size"`
6464
Dangling bool `json:"dangling"`
6565
Created int64 `json:"created"`
66+
InUse bool `json:"inUse"`
6667
}
6768

6869
type DockerImageList struct {

web/src/app/images/image-list.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export default function ImageList() {
137137
<TableHead scope="col">Id</TableHead>
138138
<TableHead scope="col">Name</TableHead>
139139
<TableHead scope="col">Tag</TableHead>
140+
<TableHead scope="col">Status</TableHead>
140141
<TableHead scope="col">Size</TableHead>
141142
<TableHead scope="col">
142143
<span className="sr-only">Actions</span>
@@ -158,6 +159,7 @@ export default function ImageList() {
158159
""
159160
)}
160161
</TableCell>
162+
<TableCell>{item.inUse ? "In use" : "Unused"}</TableCell>
161163
<TableCell>{convertByteToMb(item.size)}</TableCell>
162164
<TableCell className="text-right">
163165
<TableButtonDelete

web/src/lib/api-models.ts

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export interface IImage {
9999
size: number
100100
dangling: boolean
101101
created: number
102+
inUse: boolean
102103
}
103104

104105
export interface IVolume {

web/src/lib/version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = "1.5.4"
1+
export const VERSION = "1.5.5"

0 commit comments

Comments
 (0)