Skip to content

Commit 40172a5

Browse files
authored
Merge pull request #304 from axel7083/fix/clone-image-entrypoint-cmd
fix(clone): use alt image cmd & entrypoint
2 parents 1babd40 + 6896a2f commit 40172a5

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

__mocks__/@podman-desktop/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const plugin = {
100100
onEvent: vi.fn(),
101101
pullImage: vi.fn(),
102102
replicatePodmanContainer: vi.fn(),
103+
getImageInspect: vi.fn(),
103104
} as unknown as typeof podmanDesktopApi.containerEngine,
104105
configuration: {} as unknown as typeof podmanDesktopApi.configuration,
105106
authentication: {} as unknown as typeof podmanDesktopApi.authentication,

packages/backend/src/services/podman-service.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
ContainerEngineInfo,
2222
TelemetryLogger,
2323
CancellationToken,
24+
ImageInspectInfo,
2425
} from '@podman-desktop/api';
2526
import {
2627
extensions as extensionsAPI,
@@ -71,12 +72,20 @@ const CANCELLATION_TOKEN_MOCK: CancellationToken = {
7172
isCancellationRequested: false,
7273
} as CancellationToken;
7374

75+
const IMAGE_INSPECT_MOCK = {
76+
Config: {
77+
Entrypoint: ['entrypoint'],
78+
Cmd: ['command'],
79+
},
80+
} as unknown as ImageInspectInfo;
81+
7482
beforeEach(() => {
7583
vi.resetAllMocks();
7684

7785
vi.mocked(extensionsAPI.getExtension).mockReturnValue(PODMAN_EXTENSION_MOCK);
7886
vi.mocked(PROVIDER_SERVICE_MOCK.getContainerConnections).mockReturnValue([STARTED_PROVIDER_CONNECTION_MOCK]);
7987
vi.mocked(containerEngineAPI.listInfos).mockResolvedValue([ENGINE_INFO_MOCK]);
88+
vi.mocked(containerEngineAPI.getImageInspect).mockResolvedValue(IMAGE_INSPECT_MOCK);
8089
vi.mocked(windowAPI.withProgress).mockImplementation(async (_, task) => {
8190
return task({ report: vi.fn() }, CANCELLATION_TOKEN_MOCK);
8291
});
@@ -191,6 +200,8 @@ describe('clone', () => {
191200
image: 'alt-image',
192201
name: 'new-name',
193202
pod: 'pod-id',
203+
entrypoint: IMAGE_INSPECT_MOCK.Config.Entrypoint,
204+
command: IMAGE_INSPECT_MOCK.Config.Cmd,
194205
},
195206
);
196207

packages/backend/src/services/podman-service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export class PodmanService implements Disposable {
100100

101101
// Pull the image
102102
await containerEngineAPI.pullImage(connection.connection, alternative, console.debug, undefined, token);
103+
const alternativeInspect = await containerEngineAPI.getImageInspect(engineId, alternative);
103104

104105
// Replicate the podman container
105106
const result = await containerEngineAPI.replicatePodmanContainer(
@@ -114,6 +115,8 @@ export class PodmanService implements Disposable {
114115
image: alternative,
115116
name: options.name,
116117
pod: options.pod,
118+
entrypoint: alternativeInspect.Config.Entrypoint,
119+
command: alternativeInspect.Config.Cmd,
117120
},
118121
);
119122

0 commit comments

Comments
 (0)