What is the problem you're trying to solve
Currently image.List contains 2 steps:
- Get the images according to the filters.
- Print the images.
It'd be nice to have an exported function that only does the first step. The detailed rationale is very similar to #1837 (comment), and this time instead of directly creating a PR, I think opening an issue first probably makes more sense.
Describe the solution you'd like
Looking at the fields of types.ImageListCommandOptions, many of them are only needed by 2. Print the images, so maybe we can create a new function and make it only depend on the things it needs:
func ListTheNewFunc(ctx context.Context, namespace, address string, Filters, NameAndRefFilter []string) ([]images.Image, error)
or maybe it can just take a *containerd.Client as the caller of this function can be potentially a long-running process, and it can call clientutil.NewClient itself to instantiate the client only once during process initialization:
func ListTheNewFunc(ctx context.Context, client *containerd.Client, Filters, NameAndRefFilter []string) ([]images.Image, error)
I don't have a perfect name in mind for the new function, so I just use ListTheNewFunc as a placeholder, and I'm not even sure if creating a new function makes sense to you, and I appreciate any suggestion, thanks!
Additional context
I'm more than happy to work on this as long as the community reaches a consensus on the approach.
What is the problem you're trying to solve
Currently
image.Listcontains 2 steps:It'd be nice to have an exported function that only does the first step. The detailed rationale is very similar to #1837 (comment), and this time instead of directly creating a PR, I think opening an issue first probably makes more sense.
Describe the solution you'd like
Looking at the fields of
types.ImageListCommandOptions, many of them are only needed by2. Print the images, so maybe we can create a new function and make it only depend on the things it needs:or maybe it can just take a
*containerd.Clientas the caller of this function can be potentially a long-running process, and it can callclientutil.NewClientitself to instantiate the client only once during process initialization:I don't have a perfect name in mind for the new function, so I just use
ListTheNewFuncas a placeholder, and I'm not even sure if creating a new function makes sense to you, and I appreciate any suggestion, thanks!Additional context
I'm more than happy to work on this as long as the community reaches a consensus on the approach.