feat: show local Docker images on project detail page
- Add GET /api/projects/{id}/images endpoint returning local images matching the project
- Add ListImagesByRef with tag, size, and created timestamp to Docker client
- Display images table on project page with tag, ID (truncated), size (MB), and created date
- Only shown when Docker is available and images exist locally
This commit is contained in:
@@ -115,9 +115,11 @@ func EncodeRegistryAuth(username, password, serverAddress string) (string, error
|
||||
|
||||
// LocalImage represents a Docker image on the local machine.
|
||||
type LocalImage struct {
|
||||
ID string `json:"id"`
|
||||
Ref string `json:"ref"` // e.g., "registry/org/app:tag"
|
||||
Size int64 `json:"size"` // bytes
|
||||
ID string `json:"id"`
|
||||
Ref string `json:"ref"` // e.g., "registry/org/app:tag"
|
||||
Tag string `json:"tag"` // just the tag part
|
||||
Size int64 `json:"size"` // bytes
|
||||
Created int64 `json:"created"` // unix timestamp
|
||||
}
|
||||
|
||||
// ListImagesByRef returns all local images matching a given image reference prefix.
|
||||
@@ -132,10 +134,16 @@ func (c *Client) ListImagesByRef(ctx context.Context, imageBase string) ([]Local
|
||||
for _, img := range result.Items {
|
||||
for _, tag := range img.RepoTags {
|
||||
if strings.HasPrefix(tag, imageBase+":") || tag == imageBase {
|
||||
tagPart := ""
|
||||
if idx := strings.LastIndex(tag, ":"); idx != -1 {
|
||||
tagPart = tag[idx+1:]
|
||||
}
|
||||
images = append(images, LocalImage{
|
||||
ID: img.ID,
|
||||
Ref: tag,
|
||||
Size: img.Size,
|
||||
ID: img.ID,
|
||||
Ref: tag,
|
||||
Tag: tagPart,
|
||||
Size: img.Size,
|
||||
Created: img.Created,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user