mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-04-21 09:37:22 +00:00
fix: pass options when listing images with Docker API fallback (#16599)
* fix: pass options to Docker API fallback in podmanListImages Signed-off-by: sheikhlimon <sheikhlimon404@gmail.com>
This commit is contained in:
parent
8321210e03
commit
542fa5da6a
2 changed files with 33 additions and 5 deletions
|
|
@ -4796,6 +4796,31 @@ test('expect to fall back to compat api images if podman provider does not have
|
|||
expect(images[0]?.Id).toBe('dummyImageId2');
|
||||
});
|
||||
|
||||
test('pass options to compat api when using podmanListImages', async () => {
|
||||
const imagesList = [{ Id: 'dummyImageId' }];
|
||||
server = setupServer(http.get('http://localhost/images/json', () => HttpResponse.json(imagesList)));
|
||||
server.listen({ onUnhandledRequest: 'error' });
|
||||
|
||||
const api = new Dockerode({ protocol: 'http', host: 'localhost' });
|
||||
const listImagesSpy = vi.spyOn(api, 'listImages');
|
||||
|
||||
containerRegistry.addInternalProvider('podman', {
|
||||
name: 'podman',
|
||||
id: 'podman1',
|
||||
api,
|
||||
connection: {
|
||||
type: 'podman',
|
||||
},
|
||||
} as unknown as InternalContainerProvider);
|
||||
|
||||
await containerRegistry.podmanListImages({ all: true, filters: '{"dangling":["false"]}' });
|
||||
|
||||
expect(vi.mocked(listImagesSpy)).toHaveBeenCalledWith({
|
||||
all: true,
|
||||
filters: '{"dangling":["false"]}',
|
||||
});
|
||||
});
|
||||
|
||||
test('expect a blank array if there is no api or libpod API when doing podmanListImages', async () => {
|
||||
containerRegistry.addInternalProvider('podman', {
|
||||
name: 'podman',
|
||||
|
|
|
|||
|
|
@ -710,20 +710,23 @@ export class ContainerProviderRegistry {
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let fetchedImages: any[] = [];
|
||||
|
||||
// Create list options with explicit defaults
|
||||
const listOptions = {
|
||||
all: options?.all ?? false,
|
||||
filters: options?.filters,
|
||||
};
|
||||
|
||||
// If libpod API is available AND the configuration is set to use libpodApi, use podmanListImages API call.
|
||||
if (provider.libpodApi && this.useLibpodApiForImageList()) {
|
||||
fetchedImages = await withTimeout(
|
||||
provider.libpodApi.podmanListImages({
|
||||
all: options?.all,
|
||||
filters: options?.filters,
|
||||
}),
|
||||
provider.libpodApi.podmanListImages(listOptions),
|
||||
providerTimeoutMs,
|
||||
provider.name,
|
||||
provider.id,
|
||||
);
|
||||
} else if (provider.api) {
|
||||
fetchedImages = await withTimeout(
|
||||
provider.api.listImages({ all: false }),
|
||||
provider.api.listImages(listOptions),
|
||||
providerTimeoutMs,
|
||||
provider.name,
|
||||
provider.id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue