@exagone313/dsh-podman 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +1 -0
  2. package/README.zh.md +1 -0
  3. package/dist/approval-reasons.d.ts +12 -0
  4. package/dist/approval-reasons.js +15 -0
  5. package/dist/approval.js +21 -0
  6. package/dist/card-route.js +83 -1
  7. package/dist/client/ContainerCard.js +14 -2
  8. package/dist/client/card-protocol.d.ts +16 -1
  9. package/dist/client/container-card-controller.d.ts +8 -2
  10. package/dist/client/container-card-controller.js +21 -0
  11. package/dist/client/container-card-ports.d.ts +13 -0
  12. package/dist/client/container-card-ports.js +74 -0
  13. package/dist/client/container-card-row.d.ts +3 -0
  14. package/dist/client/container-card-row.js +12 -2
  15. package/dist/client/container-card-workspace.d.ts +3 -0
  16. package/dist/client/container-card-workspace.js +2 -2
  17. package/dist/client/index.js +653 -386
  18. package/dist/client/locales.d.ts +1 -1
  19. package/dist/client/locales.js +30 -0
  20. package/dist/client/tool-presentations.d.ts +167 -0
  21. package/dist/client/tool-presentations.js +167 -0
  22. package/dist/client/tool-views.d.ts +1 -2
  23. package/dist/client/tool-views.js +54 -190
  24. package/dist/generated/version.d.ts +2 -2
  25. package/dist/generated/version.js +2 -2
  26. package/dist/grpc/proto/dshctl/v1/control.proto +47 -1
  27. package/dist/grpc/proto/dshgateway/v1/gateway.proto +89 -0
  28. package/dist/grpc/proto/dshguest/v1/guest.proto +17 -0
  29. package/dist/index.d.ts +3 -2
  30. package/dist/index.js +3 -2
  31. package/dist/public.d.ts +1 -0
  32. package/dist/public.js +14 -0
  33. package/dist/publish-port.d.ts +6 -0
  34. package/dist/publish-port.js +37 -0
  35. package/dist/tool-defs.js +15 -1
  36. package/dist/tool-handlers.js +31 -1
  37. package/dist/tool-params.d.ts +48 -0
  38. package/dist/tool-params.js +42 -0
  39. package/docs/architecture.md +44 -7
  40. package/docs/architecture.zh.md +38 -6
  41. package/docs/configuration.md +25 -0
  42. package/docs/configuration.zh.md +23 -0
  43. package/docs/development.md +17 -6
  44. package/docs/development.zh.md +16 -6
  45. package/docs/install-dsh-and-dsh-podman.md +10 -4
  46. package/docs/install-dsh-and-dsh-podman.zh.md +9 -3
  47. package/docs/uninstall.md +4 -3
  48. package/docs/uninstall.zh.md +3 -2
  49. package/docs/update.md +23 -6
  50. package/docs/update.zh.md +23 -6
  51. package/docs/usage.md +48 -13
  52. package/docs/usage.zh.md +31 -2
  53. package/package.json +3 -1
  54. package/quadlet/dsh-podman-gateway.container +23 -0
  55. package/quadlet/dsh-podman-orchestrator.container +1 -1
  56. package/quadlet/dsh.container +1 -1
  57. package/dist/approval-reasons.test.d.ts +0 -1
  58. package/dist/approval-reasons.test.js +0 -143
  59. package/dist/approval.test.d.ts +0 -1
  60. package/dist/approval.test.js +0 -593
  61. package/dist/card-route.test.d.ts +0 -1
  62. package/dist/card-route.test.js +0 -223
  63. package/dist/card-test-support.d.ts +0 -15
  64. package/dist/card-test-support.js +0 -133
  65. package/dist/container-env.test.d.ts +0 -1
  66. package/dist/container-env.test.js +0 -93
  67. package/dist/containers.test.d.ts +0 -1
  68. package/dist/containers.test.js +0 -621
  69. package/dist/daemons.test.d.ts +0 -1
  70. package/dist/daemons.test.js +0 -167
  71. package/dist/dsh-version.test.d.ts +0 -1
  72. package/dist/dsh-version.test.js +0 -25
  73. package/dist/env-rows.test.d.ts +0 -1
  74. package/dist/env-rows.test.js +0 -43
  75. package/dist/fs-provider.test.d.ts +0 -1
  76. package/dist/fs-provider.test.js +0 -301
  77. package/dist/guest-rpc.test.d.ts +0 -1
  78. package/dist/guest-rpc.test.js +0 -241
  79. package/dist/images.test.d.ts +0 -1
  80. package/dist/images.test.js +0 -86
  81. package/dist/locales.test.d.ts +0 -1
  82. package/dist/locales.test.js +0 -34
  83. package/dist/misc.test.d.ts +0 -1
  84. package/dist/misc.test.js +0 -169
  85. package/dist/mounts.test.d.ts +0 -1
  86. package/dist/mounts.test.js +0 -478
  87. package/dist/naming.test.d.ts +0 -1
  88. package/dist/naming.test.js +0 -28
  89. package/dist/package-deps.test.d.ts +0 -1
  90. package/dist/package-deps.test.js +0 -49
  91. package/dist/paths.test.d.ts +0 -1
  92. package/dist/paths.test.js +0 -76
  93. package/dist/plugin-meta.test.d.ts +0 -1
  94. package/dist/plugin-meta.test.js +0 -29
  95. package/dist/project-path.test.d.ts +0 -1
  96. package/dist/project-path.test.js +0 -66
  97. package/dist/read-only-shell.test.d.ts +0 -1
  98. package/dist/read-only-shell.test.js +0 -182
  99. package/dist/runtime-client.test.d.ts +0 -1
  100. package/dist/runtime-client.test.js +0 -53
  101. package/dist/secrets.test.d.ts +0 -1
  102. package/dist/secrets.test.js +0 -196
  103. package/dist/settings-commands.test.d.ts +0 -1
  104. package/dist/settings-commands.test.js +0 -596
  105. package/dist/settings-create.test.d.ts +0 -1
  106. package/dist/settings-create.test.js +0 -416
  107. package/dist/settings-default-env.test.d.ts +0 -1
  108. package/dist/settings-default-env.test.js +0 -175
  109. package/dist/settings-mounts.test.d.ts +0 -1
  110. package/dist/settings-mounts.test.js +0 -506
  111. package/dist/settings-paths.test.d.ts +0 -1
  112. package/dist/settings-paths.test.js +0 -65
  113. package/dist/settings-schema.test.d.ts +0 -1
  114. package/dist/settings-schema.test.js +0 -35
  115. package/dist/settings-workspaces.test.d.ts +0 -1
  116. package/dist/settings-workspaces.test.js +0 -240
  117. package/dist/spill-store.test.d.ts +0 -1
  118. package/dist/spill-store.test.js +0 -82
  119. package/dist/subprocess.test.d.ts +0 -1
  120. package/dist/subprocess.test.js +0 -344
  121. package/dist/terminal-preference.test.d.ts +0 -1
  122. package/dist/terminal-preference.test.js +0 -62
  123. package/dist/terminal-route.test.d.ts +0 -1
  124. package/dist/terminal-route.test.js +0 -265
  125. package/dist/terminal-tab.test.d.ts +0 -1
  126. package/dist/terminal-tab.test.js +0 -58
  127. package/dist/terminal-targets.test.d.ts +0 -1
  128. package/dist/terminal-targets.test.js +0 -43
  129. package/dist/terminal-titles.test.d.ts +0 -1
  130. package/dist/terminal-titles.test.js +0 -36
  131. package/dist/test-support.d.ts +0 -358
  132. package/dist/test-support.js +0 -499
  133. package/dist/version-compat.test.d.ts +0 -1
  134. package/dist/version-compat.test.js +0 -27
  135. package/dist/views.test.d.ts +0 -1
  136. package/dist/views.test.js +0 -23
  137. package/dist/volumes.test.d.ts +0 -1
  138. package/dist/volumes.test.js +0 -40
  139. package/dist/workspace-binding.test.d.ts +0 -1
  140. package/dist/workspace-binding.test.js +0 -523
@@ -1,506 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import { test } from "node:test";
5
- import { strict as assert } from "node:assert";
6
- import { baseValue, fakeContext, fakeScope, installedMountScope, mountCommand, } from "./card-test-support.js";
7
- import { installCardCommandDriver } from "./card-test-support.js";
8
- test("create command drives createWorkspace with mounts and image", async () => {
9
- const scope = fakeScope(baseValue());
10
- const calls = [];
11
- const resolver = {
12
- getConfig: () => ({}),
13
- setConfig: () => { },
14
- async control(method, request) {
15
- calls.push([method, request]);
16
- if (method === "listContainers")
17
- return { containers: [] };
18
- if (method === "listImages")
19
- return { images: [] };
20
- if (method === "listWorkspaces")
21
- return { workspaces: [] };
22
- return {};
23
- },
24
- };
25
- await installCardCommandDriver(fakeContext(scope), resolver);
26
- await scope.update({
27
- command: {
28
- op: "create",
29
- workspace: "w1",
30
- projectName: "team",
31
- image: "img1",
32
- at: 1,
33
- mounts: [{
34
- kind: "project",
35
- project: "team",
36
- mode: "read_write",
37
- destination: "",
38
- volume: "",
39
- secret: "",
40
- }],
41
- env: {},
42
- container: "",
43
- secretEnv: {},
44
- mount: null,
45
- },
46
- });
47
- await new Promise((resolve) => setImmediate(resolve));
48
- const createCall = calls.find(([method]) => method === "createWorkspace");
49
- assert.deepEqual(createCall?.[1], {
50
- workspaceSlug: "w1",
51
- projectName: "team",
52
- imageId: "img1",
53
- mounts: [{
54
- projectName: "team",
55
- kind: "MOUNT_KIND_PROJECT",
56
- mode: "MOUNT_MODE_READ_WRITE",
57
- }],
58
- });
59
- assert.equal(scope.value.command, null);
60
- });
61
- test("container_mount_add command drives addContainerMount for each kind", async () => {
62
- const scope = fakeScope(baseValue());
63
- const calls = [];
64
- const resolver = {
65
- getConfig: () => ({}),
66
- setConfig: () => { },
67
- async control(method, request) {
68
- calls.push([method, request]);
69
- if (method === "listContainers")
70
- return { containers: [] };
71
- if (method === "listImages")
72
- return { images: [] };
73
- if (method === "listWorkspaces")
74
- return { workspaces: [] };
75
- return {};
76
- },
77
- };
78
- await installCardCommandDriver(fakeContext(scope), resolver);
79
- await scope.update({
80
- command: {
81
- op: "container_mount_add",
82
- workspace: "w1",
83
- container: "web",
84
- image: "",
85
- at: 1,
86
- mount: {
87
- kind: "project",
88
- project: "team/src",
89
- destination: "",
90
- mode: "read_only",
91
- volume: "",
92
- secret: "",
93
- },
94
- },
95
- });
96
- await new Promise((resolve) => setImmediate(resolve));
97
- await scope.update({
98
- command: {
99
- op: "container_mount_add",
100
- workspace: "w1",
101
- container: "web",
102
- image: "",
103
- at: 2,
104
- mount: {
105
- kind: "volume",
106
- project: "",
107
- destination: "/data",
108
- mode: "read_write",
109
- volume: "valkey-data",
110
- secret: "",
111
- },
112
- },
113
- });
114
- await new Promise((resolve) => setImmediate(resolve));
115
- await scope.update({
116
- command: {
117
- op: "container_mount_add",
118
- workspace: "w1",
119
- container: "web",
120
- image: "",
121
- at: 3,
122
- mount: {
123
- kind: "tmpfs",
124
- project: "",
125
- destination: "/dev/shm",
126
- mode: "read_write",
127
- volume: "",
128
- secret: "",
129
- },
130
- },
131
- });
132
- await new Promise((resolve) => setImmediate(resolve));
133
- await scope.update({
134
- command: {
135
- op: "container_mount_add",
136
- workspace: "w1",
137
- container: "",
138
- image: "",
139
- at: 4,
140
- mount: {
141
- kind: "secret",
142
- project: "",
143
- destination: "/run/secrets/tls",
144
- mode: "read_only",
145
- volume: "",
146
- secret: "valkey-tls",
147
- },
148
- },
149
- });
150
- await new Promise((resolve) => setImmediate(resolve));
151
- const addCalls = calls.filter(([method]) => method === "addContainerMount");
152
- assert.deepEqual(addCalls.map(([, request]) => request), [
153
- {
154
- workspaceSlug: "w1",
155
- container: "web",
156
- kind: "MOUNT_KIND_PROJECT",
157
- project: "team/src",
158
- mode: "MOUNT_MODE_READ_ONLY",
159
- },
160
- {
161
- workspaceSlug: "w1",
162
- container: "web",
163
- kind: "MOUNT_KIND_VOLUME",
164
- volume: "valkey-data",
165
- destination: "/data",
166
- mode: "MOUNT_MODE_READ_WRITE",
167
- },
168
- {
169
- workspaceSlug: "w1",
170
- container: "web",
171
- kind: "MOUNT_KIND_TMPFS",
172
- destination: "/dev/shm",
173
- mode: "MOUNT_MODE_READ_WRITE",
174
- },
175
- {
176
- workspaceSlug: "w1",
177
- container: "default",
178
- kind: "MOUNT_KIND_SECRET",
179
- secret: "valkey-tls",
180
- destination: "/run/secrets/tls",
181
- },
182
- ]);
183
- assert.equal(scope.value.command, null);
184
- });
185
- test("container_mount_remove command drives removeContainerMount for each kind", async () => {
186
- const scope = fakeScope(baseValue());
187
- const calls = [];
188
- const resolver = {
189
- getConfig: () => ({}),
190
- setConfig: () => { },
191
- async control(method, request) {
192
- calls.push([method, request]);
193
- if (method === "listContainers")
194
- return { containers: [] };
195
- if (method === "listImages")
196
- return { images: [] };
197
- if (method === "listWorkspaces")
198
- return { workspaces: [] };
199
- return {};
200
- },
201
- };
202
- await installCardCommandDriver(fakeContext(scope), resolver);
203
- await scope.update({
204
- command: {
205
- op: "container_mount_remove",
206
- workspace: "w1",
207
- container: "web",
208
- image: "",
209
- at: 1,
210
- mount: {
211
- kind: "project",
212
- project: "team/src",
213
- destination: "/workspace/team",
214
- mode: "read_write",
215
- volume: "",
216
- secret: "",
217
- },
218
- },
219
- });
220
- await new Promise((resolve) => setImmediate(resolve));
221
- await scope.update({
222
- command: {
223
- op: "container_mount_remove",
224
- workspace: "w1",
225
- container: "web",
226
- image: "",
227
- at: 2,
228
- mount: {
229
- kind: "volume",
230
- project: "",
231
- destination: "",
232
- mode: "read_write",
233
- volume: "valkey-data",
234
- secret: "",
235
- },
236
- },
237
- });
238
- await new Promise((resolve) => setImmediate(resolve));
239
- await scope.update({
240
- command: {
241
- op: "container_mount_remove",
242
- workspace: "w1",
243
- container: "",
244
- image: "",
245
- at: 3,
246
- mount: {
247
- kind: "tmpfs",
248
- project: "",
249
- destination: "/dev/shm",
250
- mode: "read_write",
251
- volume: "",
252
- secret: "",
253
- },
254
- },
255
- });
256
- await new Promise((resolve) => setImmediate(resolve));
257
- await scope.update({
258
- command: {
259
- op: "container_mount_remove",
260
- workspace: "w1",
261
- container: "web",
262
- image: "",
263
- at: 4,
264
- mount: {
265
- kind: "secret",
266
- project: "",
267
- destination: "/run/secrets/tls",
268
- mode: "read_write",
269
- volume: "",
270
- secret: "valkey-tls",
271
- },
272
- },
273
- });
274
- await new Promise((resolve) => setImmediate(resolve));
275
- const removeCalls = calls.filter(([method]) => method === "removeContainerMount");
276
- assert.deepEqual(removeCalls.map(([, request]) => request), [
277
- {
278
- workspaceSlug: "w1",
279
- container: "web",
280
- kind: "MOUNT_KIND_PROJECT",
281
- project: "team/src",
282
- },
283
- {
284
- workspaceSlug: "w1",
285
- container: "web",
286
- kind: "MOUNT_KIND_VOLUME",
287
- volume: "valkey-data",
288
- },
289
- {
290
- workspaceSlug: "w1",
291
- container: "default",
292
- kind: "MOUNT_KIND_TMPFS",
293
- destination: "/dev/shm",
294
- },
295
- {
296
- workspaceSlug: "w1",
297
- container: "web",
298
- kind: "MOUNT_KIND_SECRET",
299
- secret: "valkey-tls",
300
- destination: "/run/secrets/tls",
301
- },
302
- ]);
303
- assert.equal(scope.value.command, null);
304
- });
305
- test("container_mount_update command drives updateContainerMount", async () => {
306
- const { scope, calls } = await installedMountScope();
307
- await scope.update({
308
- command: mountCommand("container_mount_update", {
309
- kind: "project",
310
- project: "team",
311
- mode: "read_only",
312
- }),
313
- });
314
- await new Promise((resolve) => setImmediate(resolve));
315
- await scope.update({
316
- command: mountCommand("container_mount_update", {
317
- kind: "volume",
318
- volume: "valkey-data",
319
- destination: "/data",
320
- mode: "read_write",
321
- }),
322
- });
323
- await new Promise((resolve) => setImmediate(resolve));
324
- const updateCalls = calls.filter(([method]) => method === "updateContainerMount");
325
- assert.deepEqual(updateCalls.map(([, request]) => request), [
326
- {
327
- workspaceSlug: "w1",
328
- container: "web",
329
- kind: "MOUNT_KIND_PROJECT",
330
- project: "team",
331
- mode: "MOUNT_MODE_READ_ONLY",
332
- },
333
- {
334
- workspaceSlug: "w1",
335
- container: "web",
336
- kind: "MOUNT_KIND_VOLUME",
337
- volume: "valkey-data",
338
- destination: "/data",
339
- mode: "MOUNT_MODE_READ_WRITE",
340
- },
341
- ]);
342
- assert.equal(scope.value.command, null);
343
- });
344
- test("container_mount_add command rejects a read-write secret mount", async () => {
345
- const { scope, calls } = await installedMountScope();
346
- await scope.update({
347
- command: mountCommand("container_mount_add", {
348
- kind: "secret",
349
- secret: "valkey-tls",
350
- destination: "/run/secrets/tls",
351
- mode: "read_write",
352
- }),
353
- });
354
- await new Promise((resolve) => setImmediate(resolve));
355
- assert.equal(scope.value.notice, "secret mounts are read-only; omit mode or use read_only");
356
- assert.equal(calls.some(([method]) => method === "addContainerMount"), false, "a rejected secret mount must not reach the orchestrator");
357
- });
358
- test("container_mount_update command rejects a secret mount", async () => {
359
- const { scope, calls } = await installedMountScope();
360
- await scope.update({
361
- command: mountCommand("container_mount_update", {
362
- kind: "secret",
363
- secret: "valkey-tls",
364
- destination: "/run/secrets/tls",
365
- mode: "read_write",
366
- }),
367
- });
368
- await new Promise((resolve) => setImmediate(resolve));
369
- assert.equal(scope.value.notice, "secret mounts are read-only; omit mode or use read_only");
370
- assert.equal(calls.some(([method]) => method === "updateContainerMount"), false, "a rejected secret mount must not reach the orchestrator");
371
- });
372
- test("container_mount_add command reports an unknown kind as a notice", async () => {
373
- const { scope, calls } = await installedMountScope();
374
- await scope.update({
375
- command: mountCommand("container_mount_add", {
376
- kind: "bind",
377
- project: "team",
378
- mode: "read_write",
379
- }),
380
- });
381
- await new Promise((resolve) => setImmediate(resolve));
382
- assert.equal(scope.value.notice, "unknown mount kind: bind");
383
- assert.equal(scope.value.command, null);
384
- assert.equal(calls.some(([method]) => method === "addContainerMount"), false, "a rejected mount must not reach the orchestrator");
385
- });
386
- test("container_mount_add command reports an unknown mode as a notice", async () => {
387
- const { scope, calls } = await installedMountScope();
388
- await scope.update({
389
- command: mountCommand("container_mount_add", {
390
- kind: "project",
391
- project: "team",
392
- mode: "rw",
393
- }),
394
- });
395
- await new Promise((resolve) => setImmediate(resolve));
396
- assert.equal(scope.value.notice, "unknown mount mode: rw");
397
- assert.equal(scope.value.command, null);
398
- assert.equal(calls.some(([method]) => method === "addContainerMount"), false, "a rejected mount must not reach the orchestrator");
399
- });
400
- test("container_mount_remove command reports an unknown kind as a notice", async () => {
401
- const { scope, calls } = await installedMountScope();
402
- await scope.update({
403
- command: mountCommand("container_mount_remove", {
404
- kind: "bind",
405
- project: "team",
406
- }),
407
- });
408
- await new Promise((resolve) => setImmediate(resolve));
409
- assert.equal(scope.value.notice, "unknown mount kind: bind");
410
- assert.equal(scope.value.command, null);
411
- assert.equal(calls.some(([method]) => method === "removeContainerMount"), false, "a rejected mount must not reach the orchestrator");
412
- });
413
- test("create command reports an unknown mount kind as a notice", async () => {
414
- const { scope, calls } = await installedMountScope();
415
- await scope.update({
416
- command: {
417
- op: "create",
418
- workspace: "w1",
419
- image: "",
420
- at: 1,
421
- mounts: [{
422
- kind: "bind",
423
- project: "team",
424
- destination: "",
425
- mode: "read_write",
426
- volume: "",
427
- secret: "",
428
- }],
429
- env: {},
430
- container: "",
431
- secretEnv: {},
432
- mount: null,
433
- },
434
- });
435
- await new Promise((resolve) => setImmediate(resolve));
436
- assert.equal(scope.value.notice, "unknown mount kind: bind");
437
- assert.equal(scope.value.command, null);
438
- assert.equal(calls.some(([method]) => method === "createWorkspace"), false, "a rejected mount must not reach the orchestrator");
439
- });
440
- test("create command reports an unknown mount mode as a notice", async () => {
441
- const { scope, calls } = await installedMountScope();
442
- await scope.update({
443
- command: {
444
- op: "create",
445
- workspace: "w1",
446
- image: "",
447
- at: 1,
448
- mounts: [{
449
- kind: "project",
450
- project: "team",
451
- destination: "",
452
- mode: "rw",
453
- volume: "",
454
- secret: "",
455
- }],
456
- env: {},
457
- container: "",
458
- secretEnv: {},
459
- mount: null,
460
- },
461
- });
462
- await new Promise((resolve) => setImmediate(resolve));
463
- assert.equal(scope.value.notice, "unknown mount mode: rw");
464
- assert.equal(scope.value.command, null);
465
- assert.equal(calls.some(([method]) => method === "createWorkspace"), false, "a rejected mount must not reach the orchestrator");
466
- });
467
- test("listContainers container mounts carry the raw proto fields", async () => {
468
- const scope = fakeScope(baseValue());
469
- const resolver = {
470
- getConfig: () => ({}),
471
- setConfig: () => { },
472
- async control(method) {
473
- if (method === "listContainers") {
474
- return {
475
- containers: [{
476
- containerName: "c1",
477
- workspaceSlug: "w1",
478
- mounts: [{
479
- projectName: "team/src",
480
- destination: "/x",
481
- kind: "MOUNT_KIND_PROJECT",
482
- mode: "MOUNT_MODE_READ_WRITE",
483
- volume: "",
484
- secret: "",
485
- }],
486
- }],
487
- };
488
- }
489
- if (method === "listImages")
490
- return { images: [] };
491
- if (method === "listWorkspaces")
492
- return { workspaces: [] };
493
- return {};
494
- },
495
- };
496
- await installCardCommandDriver(fakeContext(scope), resolver);
497
- await scope.update({});
498
- assert.deepEqual(scope.value.containers[0].mounts[0], {
499
- projectName: "team/src",
500
- destination: "/x",
501
- kind: "MOUNT_KIND_PROJECT",
502
- mode: "MOUNT_MODE_READ_WRITE",
503
- volume: "",
504
- secret: "",
505
- });
506
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { baseValue, fakeContext, fakeScope } from "./card-test-support.js";
7
- import { installCardCommandDriver } from "./card-test-support.js";
8
- import { WORKSPACE_ID } from "./test-support.js";
9
- test("container_path_set command persists the list and pushes it to the guest", async () => {
10
- const scope = fakeScope(baseValue());
11
- const calls = [];
12
- const pushed = [];
13
- const guest = {
14
- setPaths: (request, _metadata, callback) => {
15
- pushed.push(request.paths);
16
- callback(null, { paths: request.paths });
17
- },
18
- };
19
- const binding = { guest, token: "t", socket: "/run/x.sock" };
20
- const resolver = {
21
- getConfig: () => ({}),
22
- setConfig: () => { },
23
- resolve: async () => binding,
24
- containerBinding: async () => binding,
25
- async control(method, request) {
26
- calls.push([method, request]);
27
- if (method === "listContainers")
28
- return { containers: [] };
29
- if (method === "listImages")
30
- return { images: [] };
31
- if (method === "listWorkspaces")
32
- return { workspaces: [] };
33
- return {};
34
- },
35
- };
36
- await installCardCommandDriver(fakeContext(scope), resolver, {
37
- list: () => [{ id: WORKSPACE_ID, path: "/projects/team" }],
38
- });
39
- await scope.update({});
40
- await new Promise((resolve) => setImmediate(resolve));
41
- calls.length = 0;
42
- await scope.update({
43
- command: {
44
- op: "container_path_set",
45
- workspace: WORKSPACE_ID,
46
- container: "default",
47
- image: "",
48
- at: 1,
49
- paths: ["/opt/bin", "/usr/local/bin"],
50
- mounts: [],
51
- },
52
- });
53
- await new Promise((resolve) => setImmediate(resolve));
54
- assert.deepEqual(calls
55
- .filter(([method]) => method === "setContainerPaths")
56
- .map(([, request]) => request), [
57
- {
58
- workspaceSlug: WORKSPACE_ID,
59
- container: "default",
60
- paths: ["/opt/bin", "/usr/local/bin"],
61
- },
62
- ]);
63
- assert.deepEqual(pushed, [["/opt/bin", "/usr/local/bin"]]);
64
- assert.equal(scope.value.command, null);
65
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,35 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { Config } from "./settings-schema.js";
7
- import { WorkspaceResolver } from "./workspace-binding.js";
8
- test("every preference is a volatile field with an empty default", () => {
9
- const config = Config({});
10
- const expected = [
11
- ["defaultImage", ""],
12
- ["uiLocale", ""],
13
- ["containerEnv", {}],
14
- ];
15
- for (const [field, value] of expected) {
16
- assert.equal(typeof config[field].get, "function", `${field} must be volatile`);
17
- assert.deepEqual(config[field].get(), value, `${field} must resolve its default`);
18
- }
19
- // The host serves the schema to the client config form: volatility must be
20
- // declared on the schema, not only in the parsed value.
21
- assert.match(JSON.stringify(Config.toJSON()), /"volatile":true/);
22
- });
23
- test("the resolver reads its config through the live reader", () => {
24
- let defaultImage = "archlinux";
25
- const resolver = new WorkspaceResolver(() => ({
26
- socketsRoot: "/run/dsh-podman",
27
- defaultImage,
28
- projectsRoot: "/projects",
29
- controlToken: "token",
30
- containerEnv: {},
31
- }), undefined);
32
- assert.equal(resolver.getConfig().defaultImage, "archlinux");
33
- defaultImage = "alpine";
34
- assert.equal(resolver.getConfig().defaultImage, "alpine", "a volatile change must be visible without rebuilding the resolver");
35
- });
@@ -1 +0,0 @@
1
- export {};