chore(images): filter images by name with wildcard pattern using Docker filter

This commit is contained in:
Pasha Sviderski
2025-10-08 12:33:13 +10:00
parent 1f9c2c873d
commit a2c6cbe633
3 changed files with 17 additions and 37 deletions
+7
View File
@@ -14,6 +14,7 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/docker/compose/v2/pkg/progress"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
dockerclient "github.com/docker/docker/client"
"github.com/docker/docker/pkg/jsonmessage"
@@ -52,6 +53,12 @@ func (cli *Client) ListImages(ctx context.Context, filter api.ImageFilter) ([]ap
}
opts := image.ListOptions{Manifests: true}
if filter.Name != "" {
opts.Filters = filters.NewArgs(
filters.Arg("reference", filter.Name),
)
}
optsBytes, err := json.Marshal(opts)
if err != nil {
return nil, fmt.Errorf("marshal options: %w", err)