Skip to content

Commit f5a8893

Browse files
committed
fix(containers): fix TS errors in fetchContainerInspect store action
- Change SET_INSPECT_DATA payload to Record<string, ContainerInspectData> to satisfy MutationsType<ContainersState> constraint - Pass namespace as --namespace=<ns> CLI arg instead of ExecOptions property, consistent with the rest of the codebase - Guard against null client before calling exec Signed-off-by: Gildas Le Nadan <3ntr0p13+github@gmail.com>
1 parent 07b91a1 commit f5a8893

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

pkg/rancher-desktop/store/container-engine.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ export const mutations = {
262262
SET_ERROR(state, error) {
263263
state.error = error;
264264
},
265-
SET_INSPECT_DATA(state, { containerId, data }: { containerId: string, data: ContainerInspectData }) {
266-
state.inspectData = { ...state.inspectData, [containerId]: data };
265+
SET_INSPECT_DATA(state, inspectData) {
266+
state.inspectData = inspectData;
267267
},
268268
SET_PARAMS(state, params: BulkParams) {
269269
let clearData = false;
@@ -395,14 +395,19 @@ export const actions = {
395395
}
396396
},
397397
async fetchContainerInspect({ commit, state }, { containerId, namespace }: { containerId: string, namespace?: string }) {
398-
const result = await state.client?.docker.cli.exec(
399-
'inspect',
400-
[containerId],
401-
{ namespace },
402-
);
398+
const { client } = state;
399+
400+
if (!client) {
401+
throw new Error('Container client is not available');
402+
}
403+
const args = [
404+
...(namespace ? [`--namespace=${ namespace }`] : []),
405+
containerId,
406+
];
407+
const result = await client.docker.cli.exec('inspect', args);
403408
const parsed = result.parseJsonObject() as ContainerInspectData[];
404409

405-
commit('SET_INSPECT_DATA', { containerId, data: parsed[0] });
410+
commit('SET_INSPECT_DATA', { ...state.inspectData, [containerId]: parsed[0] });
406411
},
407412
async fetchVolumes({ commit, getters, state }) {
408413
try {

0 commit comments

Comments
 (0)