mirror of
https://github.com/psviderski/uncloud.git
synced 2026-11-10 20:54:17 +00:00
refactor(images): simplify image name handling when listing images
This commit is contained in:
+4
-12
@@ -143,22 +143,14 @@ func list(ctx context.Context, uncli *cli.CLI, opts listOptions) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// imageRows keeps every tag visible and retains digest-only and unnamed images.
|
// imageRows keeps every stored name visible and retains digest-only and unnamed images.
|
||||||
func imageRows(images []image.Summary, machineName, store string) []imageRow {
|
func imageRows(images []image.Summary, machineName, store string) []imageRow {
|
||||||
var rows []imageRow
|
var rows []imageRow
|
||||||
for _, img := range images {
|
for _, img := range images {
|
||||||
imageRefs := api.ImageReferences(img)
|
// RepoTags includes stored digest names on containerd. RepoDigests can include derived names.
|
||||||
var imageNames []string
|
imageNames := img.RepoTags
|
||||||
for _, ref := range imageRefs {
|
|
||||||
if !strings.Contains(ref, "@") {
|
|
||||||
imageNames = append(imageNames, ref)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(imageNames) == 0 {
|
if len(imageNames) == 0 {
|
||||||
imageNames = imageRefs
|
imageNames = []string{"<untagged>"}
|
||||||
}
|
|
||||||
if len(imageNames) == 0 {
|
|
||||||
imageNames = []string{"<none>"}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imgPlatforms, _ := imagePlatforms(img)
|
imgPlatforms, _ := imagePlatforms(img)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
|||||||
Reference in New Issue
Block a user