@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.
- package/README.md +1 -0
- package/README.zh.md +1 -0
- package/dist/approval-reasons.d.ts +12 -0
- package/dist/approval-reasons.js +15 -0
- package/dist/approval.js +21 -0
- package/dist/card-route.js +83 -1
- package/dist/client/ContainerCard.js +14 -2
- package/dist/client/card-protocol.d.ts +16 -1
- package/dist/client/container-card-controller.d.ts +8 -2
- package/dist/client/container-card-controller.js +21 -0
- package/dist/client/container-card-ports.d.ts +13 -0
- package/dist/client/container-card-ports.js +74 -0
- package/dist/client/container-card-row.d.ts +3 -0
- package/dist/client/container-card-row.js +12 -2
- package/dist/client/container-card-workspace.d.ts +3 -0
- package/dist/client/container-card-workspace.js +2 -2
- package/dist/client/index.js +653 -386
- package/dist/client/locales.d.ts +1 -1
- package/dist/client/locales.js +30 -0
- package/dist/client/tool-presentations.d.ts +167 -0
- package/dist/client/tool-presentations.js +167 -0
- package/dist/client/tool-views.d.ts +1 -2
- package/dist/client/tool-views.js +54 -190
- package/dist/generated/version.d.ts +2 -2
- package/dist/generated/version.js +2 -2
- package/dist/grpc/proto/dshctl/v1/control.proto +47 -1
- package/dist/grpc/proto/dshgateway/v1/gateway.proto +89 -0
- package/dist/grpc/proto/dshguest/v1/guest.proto +17 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/public.d.ts +1 -0
- package/dist/public.js +14 -0
- package/dist/publish-port.d.ts +6 -0
- package/dist/publish-port.js +37 -0
- package/dist/tool-defs.js +15 -1
- package/dist/tool-handlers.js +31 -1
- package/dist/tool-params.d.ts +48 -0
- package/dist/tool-params.js +42 -0
- package/docs/architecture.md +44 -7
- package/docs/architecture.zh.md +38 -6
- package/docs/configuration.md +25 -0
- package/docs/configuration.zh.md +23 -0
- package/docs/development.md +17 -6
- package/docs/development.zh.md +16 -6
- package/docs/install-dsh-and-dsh-podman.md +10 -4
- package/docs/install-dsh-and-dsh-podman.zh.md +9 -3
- package/docs/uninstall.md +4 -3
- package/docs/uninstall.zh.md +3 -2
- package/docs/update.md +23 -6
- package/docs/update.zh.md +23 -6
- package/docs/usage.md +48 -13
- package/docs/usage.zh.md +31 -2
- package/package.json +3 -1
- package/quadlet/dsh-podman-gateway.container +23 -0
- package/quadlet/dsh-podman-orchestrator.container +1 -1
- package/quadlet/dsh.container +1 -1
- package/dist/approval-reasons.test.d.ts +0 -1
- package/dist/approval-reasons.test.js +0 -143
- package/dist/approval.test.d.ts +0 -1
- package/dist/approval.test.js +0 -593
- package/dist/card-route.test.d.ts +0 -1
- package/dist/card-route.test.js +0 -223
- package/dist/card-test-support.d.ts +0 -15
- package/dist/card-test-support.js +0 -133
- package/dist/container-env.test.d.ts +0 -1
- package/dist/container-env.test.js +0 -93
- package/dist/containers.test.d.ts +0 -1
- package/dist/containers.test.js +0 -621
- package/dist/daemons.test.d.ts +0 -1
- package/dist/daemons.test.js +0 -167
- package/dist/dsh-version.test.d.ts +0 -1
- package/dist/dsh-version.test.js +0 -25
- package/dist/env-rows.test.d.ts +0 -1
- package/dist/env-rows.test.js +0 -43
- package/dist/fs-provider.test.d.ts +0 -1
- package/dist/fs-provider.test.js +0 -301
- package/dist/guest-rpc.test.d.ts +0 -1
- package/dist/guest-rpc.test.js +0 -241
- package/dist/images.test.d.ts +0 -1
- package/dist/images.test.js +0 -86
- package/dist/locales.test.d.ts +0 -1
- package/dist/locales.test.js +0 -34
- package/dist/misc.test.d.ts +0 -1
- package/dist/misc.test.js +0 -169
- package/dist/mounts.test.d.ts +0 -1
- package/dist/mounts.test.js +0 -478
- package/dist/naming.test.d.ts +0 -1
- package/dist/naming.test.js +0 -28
- package/dist/package-deps.test.d.ts +0 -1
- package/dist/package-deps.test.js +0 -49
- package/dist/paths.test.d.ts +0 -1
- package/dist/paths.test.js +0 -76
- package/dist/plugin-meta.test.d.ts +0 -1
- package/dist/plugin-meta.test.js +0 -29
- package/dist/project-path.test.d.ts +0 -1
- package/dist/project-path.test.js +0 -66
- package/dist/read-only-shell.test.d.ts +0 -1
- package/dist/read-only-shell.test.js +0 -182
- package/dist/runtime-client.test.d.ts +0 -1
- package/dist/runtime-client.test.js +0 -53
- package/dist/secrets.test.d.ts +0 -1
- package/dist/secrets.test.js +0 -196
- package/dist/settings-commands.test.d.ts +0 -1
- package/dist/settings-commands.test.js +0 -596
- package/dist/settings-create.test.d.ts +0 -1
- package/dist/settings-create.test.js +0 -416
- package/dist/settings-default-env.test.d.ts +0 -1
- package/dist/settings-default-env.test.js +0 -175
- package/dist/settings-mounts.test.d.ts +0 -1
- package/dist/settings-mounts.test.js +0 -506
- package/dist/settings-paths.test.d.ts +0 -1
- package/dist/settings-paths.test.js +0 -65
- package/dist/settings-schema.test.d.ts +0 -1
- package/dist/settings-schema.test.js +0 -35
- package/dist/settings-workspaces.test.d.ts +0 -1
- package/dist/settings-workspaces.test.js +0 -240
- package/dist/spill-store.test.d.ts +0 -1
- package/dist/spill-store.test.js +0 -82
- package/dist/subprocess.test.d.ts +0 -1
- package/dist/subprocess.test.js +0 -344
- package/dist/terminal-preference.test.d.ts +0 -1
- package/dist/terminal-preference.test.js +0 -62
- package/dist/terminal-route.test.d.ts +0 -1
- package/dist/terminal-route.test.js +0 -265
- package/dist/terminal-tab.test.d.ts +0 -1
- package/dist/terminal-tab.test.js +0 -58
- package/dist/terminal-targets.test.d.ts +0 -1
- package/dist/terminal-targets.test.js +0 -43
- package/dist/terminal-titles.test.d.ts +0 -1
- package/dist/terminal-titles.test.js +0 -36
- package/dist/test-support.d.ts +0 -358
- package/dist/test-support.js +0 -499
- package/dist/version-compat.test.d.ts +0 -1
- package/dist/version-compat.test.js +0 -27
- package/dist/views.test.d.ts +0 -1
- package/dist/views.test.js +0 -23
- package/dist/volumes.test.d.ts +0 -1
- package/dist/volumes.test.js +0 -40
- package/dist/workspace-binding.test.d.ts +0 -1
- package/dist/workspace-binding.test.js +0 -523
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT
|
|
|
12
12
|
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Fdsh)
|
|
13
13
|
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Forchestrator)
|
|
14
14
|
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Fguest-agent)
|
|
15
|
+
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Fgateway)
|
|
15
16
|
|
|
16
17
|
English | [中文](README.zh.md)
|
|
17
18
|
|
package/README.zh.md
CHANGED
|
@@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT
|
|
|
12
12
|
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Fdsh)
|
|
13
13
|
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Forchestrator)
|
|
14
14
|
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Fguest-agent)
|
|
15
|
+
[](https://github.com/Exagone313/dsh-podman/pkgs/container/dsh-podman%2Fgateway)
|
|
15
16
|
|
|
16
17
|
[English](README.md) | 中文
|
|
17
18
|
|
|
@@ -41,6 +41,17 @@ export type ReasonFact = {
|
|
|
41
41
|
kind: "container_mount_update";
|
|
42
42
|
container: string;
|
|
43
43
|
mount: MountFact;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "container_publish_port";
|
|
46
|
+
container: string;
|
|
47
|
+
port: number;
|
|
48
|
+
protocol: string;
|
|
49
|
+
suggestedHostPort?: number;
|
|
50
|
+
} | {
|
|
51
|
+
kind: "container_unpublish_port";
|
|
52
|
+
container: string;
|
|
53
|
+
port: number;
|
|
54
|
+
protocol: string;
|
|
44
55
|
} | {
|
|
45
56
|
kind: "container_path_set";
|
|
46
57
|
container: string;
|
|
@@ -124,5 +135,6 @@ export declare function resolveReasonLocale(value: unknown): ReasonLocale;
|
|
|
124
135
|
export declare function reasonLocale(value: unknown): ReasonLocale;
|
|
125
136
|
export declare function renderReason(locale: ReasonLocale, fact: ReasonFact): string;
|
|
126
137
|
export declare function renderCacheCleanNotice(locale: ReasonLocale, files: number): string;
|
|
138
|
+
export declare function renderPublishNotice(locale: ReasonLocale, endpoint: string): string;
|
|
127
139
|
export declare function renderDefaultEnvSyncNotice(locale: ReasonLocale, applied: number, skipped: number): string;
|
|
128
140
|
export declare function renderDenial(locale: ReasonLocale, fact: DenialFact): string;
|
package/dist/approval-reasons.js
CHANGED
|
@@ -143,6 +143,15 @@ export function renderReason(locale, fact) {
|
|
|
143
143
|
return pick(locale, `Remove container ${quoted(locale, fact.container)}.`, `移除容器 ${quoted(locale, fact.container)}。`);
|
|
144
144
|
case "container_mount_add":
|
|
145
145
|
return pick(locale, `Add mount to container ${quoted(locale, fact.container)}: ${mountText(locale, fact.mount)}.`, `在容器 ${quoted(locale, fact.container)} 中添加挂载:${mountText(locale, fact.mount)}。`);
|
|
146
|
+
case "container_publish_port": {
|
|
147
|
+
const target = `${fact.port}/${fact.protocol}`;
|
|
148
|
+
const where = fact.suggestedHostPort === undefined
|
|
149
|
+
? pick(locale, "a free host port", "主机上的一个空闲端口")
|
|
150
|
+
: pick(locale, `the host port ${fact.suggestedHostPort}`, `主机端口 ${fact.suggestedHostPort}`);
|
|
151
|
+
return pick(locale, `Publish ${target} from container ${quoted(locale, fact.container)} on ${where}; it becomes reachable on the host.`, `将容器 ${quoted(locale, fact.container)} 的 ${target} 发布到${where};主机将可访问该端口。`);
|
|
152
|
+
}
|
|
153
|
+
case "container_unpublish_port":
|
|
154
|
+
return pick(locale, `Stop publishing ${fact.port}/${fact.protocol} from container ${quoted(locale, fact.container)}.`, `停止发布容器 ${quoted(locale, fact.container)} 的 ${fact.port}/${fact.protocol}。`);
|
|
146
155
|
case "container_mount_remove":
|
|
147
156
|
return pick(locale, `Remove mount from container ${quoted(locale, fact.container)}: ${mountText(locale, fact.mount)}.`, `从容器 ${quoted(locale, fact.container)} 中移除挂载:${mountText(locale, fact.mount)}。`);
|
|
148
157
|
case "container_mount_update": {
|
|
@@ -208,6 +217,12 @@ export function renderReason(locale, fact) {
|
|
|
208
217
|
export function renderCacheCleanNotice(locale, files) {
|
|
209
218
|
return pick(locale, `removed ${files} cached ${files === 1 ? "file" : "files"}`, `已移除 ${files} 个缓存文件`);
|
|
210
219
|
}
|
|
220
|
+
// Render the settings notice shown after a port was published. The gateway may
|
|
221
|
+
// have chosen the host port when the caller suggested none, so the notice names
|
|
222
|
+
// the endpoint it reported rather than the port that was asked for.
|
|
223
|
+
export function renderPublishNotice(locale, endpoint) {
|
|
224
|
+
return pick(locale, `published on ${endpoint}`, `已发布到 ${endpoint}`);
|
|
225
|
+
}
|
|
211
226
|
// Render the settings notice shown after the default environment was applied
|
|
212
227
|
// to existing containers: how many were recreated, and how many stopped
|
|
213
228
|
// containers were left for their next start.
|
package/dist/approval.js
CHANGED
|
@@ -141,6 +141,27 @@ export function reasonFact(name, args, sessionCwd) {
|
|
|
141
141
|
? undefined
|
|
142
142
|
: { kind: "container_remove", container };
|
|
143
143
|
}
|
|
144
|
+
case "container_publish_port":
|
|
145
|
+
case "container_unpublish_port": {
|
|
146
|
+
const container = str("container");
|
|
147
|
+
const port = typeof args.port === "number" ? args.port : undefined;
|
|
148
|
+
if (container === undefined || port === undefined)
|
|
149
|
+
return undefined;
|
|
150
|
+
const protocol = str("protocol") ?? "tcp";
|
|
151
|
+
if (name === "container_unpublish_port") {
|
|
152
|
+
return { kind: "container_unpublish_port", container, port, protocol };
|
|
153
|
+
}
|
|
154
|
+
const suggestedHostPort = typeof args.suggestedHostPort === "number"
|
|
155
|
+
? args.suggestedHostPort
|
|
156
|
+
: undefined;
|
|
157
|
+
return {
|
|
158
|
+
kind: "container_publish_port",
|
|
159
|
+
container,
|
|
160
|
+
port,
|
|
161
|
+
protocol,
|
|
162
|
+
...(suggestedHostPort === undefined ? {} : { suggestedHostPort }),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
144
165
|
case "volume_remove": {
|
|
145
166
|
const volume = str("name");
|
|
146
167
|
return volume === undefined
|
package/dist/card-route.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
// request, so neither the snapshot nor the commands touch the persisted
|
|
7
7
|
// settings document.
|
|
8
8
|
import { CARD_PATH, } from "./client/card-protocol.js";
|
|
9
|
-
import { renderCacheCleanNotice, renderDefaultEnvSyncNotice, resolveReasonLocale, } from "./approval-reasons.js";
|
|
9
|
+
import { renderCacheCleanNotice, renderDefaultEnvSyncNotice, renderPublishNotice, resolveReasonLocale, } from "./approval-reasons.js";
|
|
10
10
|
import { mergeDefaultEnv, missingDefaultEnv } from "./container-env.js";
|
|
11
|
+
import { portProtocolFromProto, portProtocolToProto } from "./publish-port.js";
|
|
11
12
|
import { defaultMountMode, mountKindToProto, mountModeToProto, } from "./mount-enums.js";
|
|
12
13
|
import { mountInputToProto, validateMountInput } from "./mount-input.js";
|
|
13
14
|
import { unaryGuest } from "./guest-rpc.js";
|
|
@@ -26,6 +27,33 @@ async function readOrchestratorVersion(resolver) {
|
|
|
26
27
|
return "";
|
|
27
28
|
}
|
|
28
29
|
}
|
|
30
|
+
// The gateway states the control plane reports, mapped to the card's
|
|
31
|
+
// vocabulary. Anything else, including a status an older orchestrator cannot
|
|
32
|
+
// answer, reads as "unknown".
|
|
33
|
+
const GATEWAY_STATES = {
|
|
34
|
+
GATEWAY_STATE_RUNNING: "running",
|
|
35
|
+
GATEWAY_STATE_ABSENT: "absent",
|
|
36
|
+
GATEWAY_STATE_INCOMPATIBLE: "incompatible",
|
|
37
|
+
};
|
|
38
|
+
// readGatewayStatus asks the orchestrator for the optional gateway's cached
|
|
39
|
+
// status, or reports it unknown when the RPC is missing (an older orchestrator)
|
|
40
|
+
// or fails. It never dials the gateway itself.
|
|
41
|
+
async function readGatewayStatus(resolver) {
|
|
42
|
+
try {
|
|
43
|
+
const response = await resolver.control("getGatewayStatus", {});
|
|
44
|
+
const proto = String(response?.state ?? "");
|
|
45
|
+
return {
|
|
46
|
+
gatewayState: Object.prototype.hasOwnProperty.call(GATEWAY_STATES, proto)
|
|
47
|
+
? GATEWAY_STATES[proto]
|
|
48
|
+
: "unknown",
|
|
49
|
+
gatewayVersion: String(response?.version ?? ""),
|
|
50
|
+
gatewayCommit: String(response?.commit ?? ""),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return { gatewayState: "unknown", gatewayVersion: "", gatewayCommit: "" };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
29
57
|
// The cache clean modes the settings card can request, mapped to the control
|
|
30
58
|
// plane's enum names.
|
|
31
59
|
const CACHE_CLEAN_MODES = {
|
|
@@ -53,6 +81,20 @@ function containerMountView(mount) {
|
|
|
53
81
|
secret: stringField(mount?.secret),
|
|
54
82
|
};
|
|
55
83
|
}
|
|
84
|
+
// publishedPortView keeps the address the gateway chose; the proto row also
|
|
85
|
+
// carries the container name, which the surrounding row already knows. The card
|
|
86
|
+
// works in logical protocol names ("tcp"), and an unknown enum value is kept
|
|
87
|
+
// verbatim so a newer orchestrator is not silently mislabelled.
|
|
88
|
+
function publishedPortView(port) {
|
|
89
|
+
const proto = stringField(port?.protocol);
|
|
90
|
+
return {
|
|
91
|
+
protocol: portProtocolFromProto(proto) ?? proto,
|
|
92
|
+
port: Number(port?.port ?? 0),
|
|
93
|
+
address: stringField(port?.address),
|
|
94
|
+
hostPort: Number(port?.hostPort ?? 0),
|
|
95
|
+
endpoint: stringField(port?.endpoint),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
56
98
|
function imageView(image) {
|
|
57
99
|
return {
|
|
58
100
|
imageId: stringField(image?.imageId),
|
|
@@ -136,6 +178,7 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
|
|
|
136
178
|
// succeeds even when the rest is refused; an older orchestrator that has no
|
|
137
179
|
// GetVersion yet leaves the version unknown.
|
|
138
180
|
const orchestratorVersion = await readOrchestratorVersion(resolver);
|
|
181
|
+
const gateway = await readGatewayStatus(resolver);
|
|
139
182
|
let listings;
|
|
140
183
|
try {
|
|
141
184
|
listings = await Promise.all([
|
|
@@ -159,6 +202,8 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
|
|
|
159
202
|
dshVersion: harnessVersion,
|
|
160
203
|
orchestratorVersion,
|
|
161
204
|
versionState: "major-mismatch",
|
|
205
|
+
...gateway,
|
|
206
|
+
gatewayVersionState: "ok",
|
|
162
207
|
projectsRoot: resolver.getConfig().projectsRoot,
|
|
163
208
|
workspaces: [],
|
|
164
209
|
containers: [],
|
|
@@ -175,6 +220,11 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
|
|
|
175
220
|
dshVersion: harnessVersion,
|
|
176
221
|
orchestratorVersion,
|
|
177
222
|
versionState: pluginVersionState(VERSION, orchestratorVersion),
|
|
223
|
+
...gateway,
|
|
224
|
+
// Absent or unreadable is not a mismatch: the gateway is optional.
|
|
225
|
+
gatewayVersionState: gateway.gatewayVersion === ""
|
|
226
|
+
? "ok"
|
|
227
|
+
: pluginVersionState(gateway.gatewayVersion, orchestratorVersion || VERSION),
|
|
178
228
|
projectsRoot: resolver.getConfig().projectsRoot,
|
|
179
229
|
workspaces: mergeWorkspaceViews(dshWorkspaceViews(workspaceRegistry, resolver.getConfig().projectsRoot), orchestratorWorkspaceViews(workspaces.workspaces)),
|
|
180
230
|
containers: (containers.containers ?? []).map((container) => ({
|
|
@@ -187,6 +237,7 @@ export async function cardSnapshot(resolver, workspaceRegistry, harnessVersion =
|
|
|
187
237
|
paths: container.paths ?? [],
|
|
188
238
|
env: container.env ?? {},
|
|
189
239
|
secretEnv: container.secretEnv ?? {},
|
|
240
|
+
publishedPorts: (container.publishedPorts ?? []).map(publishedPortView),
|
|
190
241
|
})),
|
|
191
242
|
images: (images.images ?? []).map(imageView),
|
|
192
243
|
volumes: (volumes.volumes ?? []).map((volume) => ({
|
|
@@ -333,6 +384,32 @@ readLocale) {
|
|
|
333
384
|
await resolver.control("updateContainerMount", request);
|
|
334
385
|
break;
|
|
335
386
|
}
|
|
387
|
+
case "container_publish_port": {
|
|
388
|
+
// A published port belongs to the pod, not to the workspace's mounts, so
|
|
389
|
+
// the orchestrator does the validation; the card only mirrors it.
|
|
390
|
+
const request = {
|
|
391
|
+
workspaceSlug: command.workspace,
|
|
392
|
+
container: command.container || "default",
|
|
393
|
+
port: command.port,
|
|
394
|
+
protocol: portProtocolToProto(command.protocol === "" ? "tcp" : command.protocol),
|
|
395
|
+
};
|
|
396
|
+
if (command.suggestedHostPort > 0) {
|
|
397
|
+
request.suggestedHostPort = command.suggestedHostPort;
|
|
398
|
+
}
|
|
399
|
+
const published = (await resolver.control("publishPort", request));
|
|
400
|
+
// A random host port is only knowable from the answer, so the notice
|
|
401
|
+
// names the endpoint the gateway actually bound.
|
|
402
|
+
notice = renderPublishNotice(resolveReasonLocale(readLocale?.()), stringField(published?.endpoint));
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case "container_unpublish_port":
|
|
406
|
+
await resolver.control("unpublishPort", {
|
|
407
|
+
workspaceSlug: command.workspace,
|
|
408
|
+
container: command.container || "default",
|
|
409
|
+
port: command.port,
|
|
410
|
+
protocol: portProtocolToProto(command.protocol === "" ? "tcp" : command.protocol),
|
|
411
|
+
});
|
|
412
|
+
break;
|
|
336
413
|
case "container_path_set": {
|
|
337
414
|
const paths = [...command.paths];
|
|
338
415
|
await resolver.control("setContainerPaths", {
|
|
@@ -535,6 +612,11 @@ function normalizeCommand(raw) {
|
|
|
535
612
|
secretEnv: stringMap(raw.secretEnv),
|
|
536
613
|
cacheMode: stringField(raw.cacheMode),
|
|
537
614
|
mount: mountField(raw.mount),
|
|
615
|
+
port: typeof raw.port === "number" ? raw.port : 0,
|
|
616
|
+
protocol: stringField(raw.protocol),
|
|
617
|
+
suggestedHostPort: typeof raw.suggestedHostPort === "number"
|
|
618
|
+
? raw.suggestedHostPort
|
|
619
|
+
: 0,
|
|
538
620
|
};
|
|
539
621
|
}
|
|
540
622
|
async function handleCardRequest(request, ctx, resolver, workspaceRegistry, readLocale, harnessVersion) {
|
|
@@ -32,6 +32,11 @@ export function ContainerCard(props) {
|
|
|
32
32
|
`${t("dsh")} ${state.dshVersion || t("versionUnknown")}`,
|
|
33
33
|
`${t("cardTitle")} ${state.version}${state.commit ? ` · ${state.commit}` : ""}`,
|
|
34
34
|
`${t("orchestrator")} ${state.orchestratorVersion || t("versionUnknown")}`,
|
|
35
|
+
`${t("gateway")} ${state.gatewayState === "running"
|
|
36
|
+
? `${state.gatewayVersion}${state.gatewayCommit ? ` · ${state.gatewayCommit}` : ""}`
|
|
37
|
+
: state.gatewayState === "incompatible"
|
|
38
|
+
? t("gatewayIncompatible")
|
|
39
|
+
: t("gatewayNotRunning")}`,
|
|
35
40
|
];
|
|
36
41
|
setCopyState((await writeClipboard(lines.join("\n"))) ? "copied" : "failed");
|
|
37
42
|
if (copyResetTimer.current !== undefined) {
|
|
@@ -74,7 +79,8 @@ export function ContainerCard(props) {
|
|
|
74
79
|
? { ...banner, borderColor: "var(--dsw-alias-state-error-primary)" }
|
|
75
80
|
: banner, role: state.versionState === "major-mismatch" ? "alert" : "status", children: t(state.versionState === "major-mismatch"
|
|
76
81
|
? "versionMismatchMajor"
|
|
77
|
-
: "versionMismatchMinor") })), _jsx("div", { style: sectionTitle, children: t("workspacesTitle") }), state.workspaces.length === 0 ? _jsx("p", { style: hint, children: t("none") }) : (state.workspaces.map((workspace) => (_jsx(WorkspaceSection, { t: t, workspace: workspace, containers: state.containers.filter((container) => container.workspaceSlug === workspace.workspaceSlug), images: state.images, volumes: state.volumes, secrets: state.secrets, busy: state.busy, defaultImage: state.defaultImage, projectsRoot: state.projectsRoot, directoryPicker: state.directoryPicker, onRemove: props.remove, onRemoveWorkspace: props.removeWorkspace, onRecreate: props.recreate, onCreate: props.createContainer, onStartContainer: props.startContainer, onAddContainerMount: props.addContainerMount, onRemoveContainerMount: props.removeContainerMount, onUpdateContainerMount: props.updateContainerMount, onSetContainerPaths: props.setContainerPaths, onAddContainerSecret: props.addContainerSecret, onRemoveContainerSecret: props.removeContainerSecret,
|
|
82
|
+
: "versionMismatchMinor") })), _jsx("div", { style: sectionTitle, children: t("workspacesTitle") }), state.workspaces.length === 0 ? _jsx("p", { style: hint, children: t("none") }) : (state.workspaces.map((workspace) => (_jsx(WorkspaceSection, { t: t, workspace: workspace, containers: state.containers.filter((container) => container.workspaceSlug === workspace.workspaceSlug), images: state.images, volumes: state.volumes, secrets: state.secrets, busy: state.busy, defaultImage: state.defaultImage, projectsRoot: state.projectsRoot, directoryPicker: state.directoryPicker, onRemove: props.remove, onRemoveWorkspace: props.removeWorkspace, onRecreate: props.recreate, onCreate: props.createContainer, onStartContainer: props.startContainer, onAddContainerMount: props.addContainerMount, onRemoveContainerMount: props.removeContainerMount, onUpdateContainerMount: props.updateContainerMount, onSetContainerPaths: props.setContainerPaths, onAddContainerSecret: props.addContainerSecret, onRemoveContainerSecret: props.removeContainerSecret, onPublishContainerPort: props.publishContainerPort, onUnpublishContainerPort: props.unpublishContainerPort, gatewayUnavailable: state.gatewayState === "absent" ||
|
|
83
|
+
state.gatewayState === "incompatible", onSyncDefaults: props.syncDefaultEnv, defaultEnvCount: Object.keys(state.containerEnv).length }, workspace.workspaceSlug)))), _jsxs("div", { style: {
|
|
78
84
|
display: "flex",
|
|
79
85
|
flexWrap: "wrap",
|
|
80
86
|
alignItems: "center",
|
|
@@ -117,5 +123,11 @@ export function ContainerCard(props) {
|
|
|
117
123
|
? (` ${state.dshVersion}`)
|
|
118
124
|
: (_jsxs(_Fragment, { children: [" ", _jsx("span", { style: { color: "var(--dsw-alias-state-error-primary)" }, children: t("versionUnknown") })] }))] }), _jsxs("span", { children: [_jsx("span", { style: versionLabel, children: t("cardTitle") }), state.version ? ` ${state.version}` : "", state.commit ? ` · ${state.commit}` : ""] }), _jsxs("span", { children: [_jsx("span", { style: versionLabel, children: t("orchestrator") }), state.orchestratorVersion
|
|
119
125
|
? (` ${state.orchestratorVersion}`)
|
|
120
|
-
: (_jsxs(_Fragment, { children: [" ", _jsx("span", { style: { color: "var(--dsw-alias-state-error-primary)" }, children: t("versionUnknown") })] }))] })
|
|
126
|
+
: (_jsxs(_Fragment, { children: [" ", _jsx("span", { style: { color: "var(--dsw-alias-state-error-primary)" }, children: t("versionUnknown") })] }))] }), _jsxs("span", { children: [_jsx("span", { style: versionLabel, children: t("gateway") }), state.gatewayState === "running"
|
|
127
|
+
? ` ${state.gatewayVersion}${state.gatewayCommit ? ` · ${state.gatewayCommit}` : ""}`
|
|
128
|
+
: (_jsxs(_Fragment, { children: [" ", _jsx("span", { style: state.gatewayState === "incompatible"
|
|
129
|
+
? { color: "var(--dsw-alias-state-error-primary)" }
|
|
130
|
+
: undefined, children: state.gatewayState === "incompatible"
|
|
131
|
+
? t("gatewayIncompatible")
|
|
132
|
+
: t("gatewayNotRunning") })] }))] })] }), _jsx("div", { style: footerRow, children: _jsx(Button, { variant: "outline", size: "sm", disabled: state.busy, onClick: props.reload, children: state.busy ? t("busy") : t("reload") }) })] }));
|
|
121
133
|
}
|
|
@@ -7,7 +7,7 @@ export interface MountInput {
|
|
|
7
7
|
volume: string;
|
|
8
8
|
secret: string;
|
|
9
9
|
}
|
|
10
|
-
export type CommandOp = "remove" | "workspace_remove" | "recreate" | "create" | "volume_create" | "volume_remove" | "image_remove" | "secret_create" | "secret_remove" | "secret_set" | "image_rebuild" | "image_rebuild_all" | "image_build" | "image_base_rebuild" | "image_base_pull" | "container_secret_add" | "container_secret_remove" | "container_mount_add" | "container_mount_remove" | "container_mount_update" | "container_path_set" | "default_env_sync" | "cache_clean";
|
|
10
|
+
export type CommandOp = "remove" | "workspace_remove" | "recreate" | "create" | "volume_create" | "volume_remove" | "image_remove" | "secret_create" | "secret_remove" | "secret_set" | "image_rebuild" | "image_rebuild_all" | "image_build" | "image_base_rebuild" | "image_base_pull" | "container_secret_add" | "container_secret_remove" | "container_mount_add" | "container_mount_remove" | "container_mount_update" | "container_publish_port" | "container_unpublish_port" | "container_path_set" | "default_env_sync" | "cache_clean";
|
|
11
11
|
export interface CommandRequest {
|
|
12
12
|
op: CommandOp;
|
|
13
13
|
workspace: string;
|
|
@@ -26,6 +26,16 @@ export interface CommandRequest {
|
|
|
26
26
|
secretEnv: Record<string, string>;
|
|
27
27
|
cacheMode: string;
|
|
28
28
|
mount: MountInput | null;
|
|
29
|
+
port: number;
|
|
30
|
+
protocol: string;
|
|
31
|
+
suggestedHostPort: number;
|
|
32
|
+
}
|
|
33
|
+
export interface PublishedPortView {
|
|
34
|
+
protocol: string;
|
|
35
|
+
port: number;
|
|
36
|
+
address: string;
|
|
37
|
+
hostPort: number;
|
|
38
|
+
endpoint: string;
|
|
29
39
|
}
|
|
30
40
|
export interface ContainerView {
|
|
31
41
|
containerName: string;
|
|
@@ -44,6 +54,7 @@ export interface ContainerView {
|
|
|
44
54
|
paths: readonly string[];
|
|
45
55
|
env: Record<string, string>;
|
|
46
56
|
secretEnv: Record<string, string>;
|
|
57
|
+
publishedPorts: readonly PublishedPortView[];
|
|
47
58
|
}
|
|
48
59
|
export interface ImageView {
|
|
49
60
|
imageId: string;
|
|
@@ -88,6 +99,10 @@ export interface CardSnapshot {
|
|
|
88
99
|
dshVersion: string;
|
|
89
100
|
orchestratorVersion: string;
|
|
90
101
|
versionState: "ok" | "minor-mismatch" | "major-mismatch";
|
|
102
|
+
gatewayState: "unknown" | "running" | "absent" | "incompatible";
|
|
103
|
+
gatewayVersion: string;
|
|
104
|
+
gatewayCommit: string;
|
|
105
|
+
gatewayVersionState: "ok" | "minor-mismatch" | "major-mismatch";
|
|
91
106
|
projectsRoot: string;
|
|
92
107
|
workspaces: readonly WorkspaceView[];
|
|
93
108
|
containers: readonly ContainerView[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SnapshotStore } from "@deepseek-ai/dsh-client-store";
|
|
2
2
|
import type { ConfigForm, ConfigFormSnapshot } from "@deepseek-ai/dsh-client-ui-settings/client";
|
|
3
|
-
import type { CacheView, ContainerView, ImageView, MountInput, SecretView, VolumeView, WorkspaceView } from "./card-protocol.js";
|
|
3
|
+
import type { CacheView, ContainerView, ImageView, MountInput, PublishedPortView, SecretView, VolumeView, WorkspaceView } from "./card-protocol.js";
|
|
4
4
|
import { type CardClient } from "./card-client.js";
|
|
5
5
|
import { type DirectoryPickerFace } from "./directory-picker.js";
|
|
6
6
|
export declare const CONTAINER_NS = "podman";
|
|
@@ -24,7 +24,7 @@ export interface ContainerCreateConfig {
|
|
|
24
24
|
paths?: readonly string[];
|
|
25
25
|
secretEnv?: Record<string, string>;
|
|
26
26
|
}
|
|
27
|
-
export type { CacheView, ContainerView, ImageView, MountInput, SecretView, VolumeView, WorkspaceView, };
|
|
27
|
+
export type { CacheView, ContainerView, ImageView, MountInput, PublishedPortView, SecretView, VolumeView, WorkspaceView, };
|
|
28
28
|
export interface CardState {
|
|
29
29
|
available: boolean;
|
|
30
30
|
writable: boolean;
|
|
@@ -35,6 +35,10 @@ export interface CardState {
|
|
|
35
35
|
dshVersion: string;
|
|
36
36
|
orchestratorVersion: string;
|
|
37
37
|
versionState: "ok" | "minor-mismatch" | "major-mismatch";
|
|
38
|
+
gatewayState: "unknown" | "running" | "absent" | "incompatible";
|
|
39
|
+
gatewayVersion: string;
|
|
40
|
+
gatewayCommit: string;
|
|
41
|
+
gatewayVersionState: "ok" | "minor-mismatch" | "major-mismatch";
|
|
38
42
|
defaultImage: string;
|
|
39
43
|
containerEnv: Record<string, string>;
|
|
40
44
|
projectsRoot: string;
|
|
@@ -61,6 +65,8 @@ export interface ContainerCardFace {
|
|
|
61
65
|
removeContainerMount: (workspace: string, container: string, mount: MountInput) => void;
|
|
62
66
|
updateContainerMount: (workspace: string, container: string, mount: MountInput) => void;
|
|
63
67
|
setContainerPaths: (workspace: string, container: string, paths: readonly string[]) => void;
|
|
68
|
+
publishContainerPort: (workspace: string, container: string, port: number, suggestedHostPort?: number) => void;
|
|
69
|
+
unpublishContainerPort: (workspace: string, container: string, port: number, protocol: string) => void;
|
|
64
70
|
createVolume: (name: string) => void;
|
|
65
71
|
removeVolume: (name: string) => void;
|
|
66
72
|
removeImage: (imageId: string) => void;
|
|
@@ -10,6 +10,10 @@ const EMPTY_SNAPSHOT = {
|
|
|
10
10
|
dshVersion: "",
|
|
11
11
|
orchestratorVersion: "",
|
|
12
12
|
versionState: "ok",
|
|
13
|
+
gatewayState: "unknown",
|
|
14
|
+
gatewayVersion: "",
|
|
15
|
+
gatewayCommit: "",
|
|
16
|
+
gatewayVersionState: "ok",
|
|
13
17
|
projectsRoot: "",
|
|
14
18
|
workspaces: [],
|
|
15
19
|
containers: [],
|
|
@@ -58,6 +62,10 @@ export class ContainerCardController {
|
|
|
58
62
|
dshVersion: this.snapshot.dshVersion,
|
|
59
63
|
orchestratorVersion: this.snapshot.orchestratorVersion,
|
|
60
64
|
versionState: this.snapshot.versionState,
|
|
65
|
+
gatewayState: this.snapshot.gatewayState,
|
|
66
|
+
gatewayVersion: this.snapshot.gatewayVersion,
|
|
67
|
+
gatewayCommit: this.snapshot.gatewayCommit,
|
|
68
|
+
gatewayVersionState: this.snapshot.gatewayVersionState,
|
|
61
69
|
defaultImage: value?.defaultImage ?? "",
|
|
62
70
|
containerEnv: value?.containerEnv ?? {},
|
|
63
71
|
projectsRoot: this.snapshot.projectsRoot,
|
|
@@ -100,6 +108,9 @@ export class ContainerCardController {
|
|
|
100
108
|
secretEnv: extra.secretEnv ?? {},
|
|
101
109
|
cacheMode: extra.cacheMode ?? "",
|
|
102
110
|
mount: extra.mount ?? null,
|
|
111
|
+
port: extra.port ?? 0,
|
|
112
|
+
protocol: extra.protocol ?? "",
|
|
113
|
+
suggestedHostPort: extra.suggestedHostPort ?? 0,
|
|
103
114
|
});
|
|
104
115
|
}
|
|
105
116
|
async dispatch(request) {
|
|
@@ -220,6 +231,16 @@ export class ContainerCardController {
|
|
|
220
231
|
mount,
|
|
221
232
|
}),
|
|
222
233
|
setContainerPaths: (workspace, container, paths) => this.command("container_path_set", workspace, "", { container, paths }),
|
|
234
|
+
publishContainerPort: (workspace, container, port, suggestedHostPort) => this.command("container_publish_port", workspace, "", {
|
|
235
|
+
container,
|
|
236
|
+
port,
|
|
237
|
+
...(suggestedHostPort ? { suggestedHostPort } : {}),
|
|
238
|
+
}),
|
|
239
|
+
unpublishContainerPort: (workspace, container, port, protocol) => this.command("container_unpublish_port", workspace, "", {
|
|
240
|
+
container,
|
|
241
|
+
port,
|
|
242
|
+
protocol,
|
|
243
|
+
}),
|
|
223
244
|
createVolume: (name) => this.command("volume_create", name, ""),
|
|
224
245
|
removeVolume: (name) => this.command("volume_remove", name, ""),
|
|
225
246
|
removeImage: (imageId) => this.command("image_remove", imageId, ""),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PublishedPortView } from "./container-card-controller.js";
|
|
2
|
+
import type { Translate } from "./locales.js";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
export declare function PortsEditor(props: {
|
|
5
|
+
t: Translate;
|
|
6
|
+
ports: readonly PublishedPortView[];
|
|
7
|
+
busy: boolean;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
canPublish: boolean;
|
|
10
|
+
gatewayUnavailable: boolean;
|
|
11
|
+
onPublish: (port: number, suggestedHostPort?: number) => void;
|
|
12
|
+
onUnpublish: (port: number, protocol: string) => void;
|
|
13
|
+
}): ReactNode;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ConfirmButton } from "./container-card-shared.js";
|
|
3
|
+
import { greyId, hint } from "./container-card-styles.js";
|
|
4
|
+
import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
// The pod-port range a published port may name, and the host-port range the
|
|
7
|
+
// gateway binds from (it never binds a privileged port).
|
|
8
|
+
const MIN_PORT = 1;
|
|
9
|
+
const MAX_PORT = 65535;
|
|
10
|
+
const MIN_HOST_PORT = 1024;
|
|
11
|
+
const MAX_HOST_PORT = 65535;
|
|
12
|
+
function parsePort(value) {
|
|
13
|
+
if (!/^[0-9]+$/.test(value))
|
|
14
|
+
return undefined;
|
|
15
|
+
const port = Number(value);
|
|
16
|
+
return port >= MIN_PORT && port <= MAX_PORT ? port : undefined;
|
|
17
|
+
}
|
|
18
|
+
function parseHostPort(value) {
|
|
19
|
+
if (!/^[0-9]+$/.test(value))
|
|
20
|
+
return undefined;
|
|
21
|
+
const port = Number(value);
|
|
22
|
+
return port >= MIN_HOST_PORT && port <= MAX_HOST_PORT ? port : undefined;
|
|
23
|
+
}
|
|
24
|
+
// PortsEditor lists what a container publishes and publishes one more. The
|
|
25
|
+
// orchestrator is the only boundary: an out-of-range value is refused here so
|
|
26
|
+
// the common mistake never leaves the browser, and everything else (a taken
|
|
27
|
+
// host port, a stopped container, a missing gateway) comes back as the card's
|
|
28
|
+
// notice.
|
|
29
|
+
export function PortsEditor(props) {
|
|
30
|
+
const { t, ports, enabled, canPublish, gatewayUnavailable, onPublish, onUnpublish, } = props;
|
|
31
|
+
const [port, setPort] = useState("");
|
|
32
|
+
const [hostPort, setHostPort] = useState("");
|
|
33
|
+
const podPort = parsePort(port);
|
|
34
|
+
// An empty suggestion asks the gateway for a free host port; a filled one must
|
|
35
|
+
// be in range before the publish leaves the browser.
|
|
36
|
+
const suggested = hostPort === "" ? undefined : parseHostPort(hostPort);
|
|
37
|
+
const hostPortInvalid = hostPort !== "" && suggested === undefined;
|
|
38
|
+
const submit = () => {
|
|
39
|
+
if (podPort === undefined || !canPublish || hostPortInvalid)
|
|
40
|
+
return;
|
|
41
|
+
onPublish(podPort, suggested);
|
|
42
|
+
setPort("");
|
|
43
|
+
setHostPort("");
|
|
44
|
+
};
|
|
45
|
+
const rowStyle = {
|
|
46
|
+
display: "flex",
|
|
47
|
+
flexWrap: "wrap",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
gap: "8px",
|
|
50
|
+
};
|
|
51
|
+
return (_jsxs(_Fragment, { children: [ports.length === 0 ? _jsx("p", { style: hint, children: t("none") }) : (ports.map((published) => (_jsxs("div", { style: rowStyle, children: [_jsx("code", { style: {
|
|
52
|
+
...greyId,
|
|
53
|
+
flex: 1,
|
|
54
|
+
fontSize: "13px",
|
|
55
|
+
color: "var(--dsw-alias-label-primary)",
|
|
56
|
+
}, children: published.endpoint }), _jsx(ConfirmButton, { t: t, label: t("unpublishPort"), title: t("confirmTitle"), description: t("confirmUnpublishPort", {
|
|
57
|
+
port: String(published.port),
|
|
58
|
+
protocol: published.protocol,
|
|
59
|
+
}), disabled: !enabled, onConfirm: () => onUnpublish(published.port, published.protocol) })] }, `${published.protocol}/${published.port}`)))), canPublish || !enabled
|
|
60
|
+
? null
|
|
61
|
+
: (_jsx("p", { style: { ...hint, paddingTop: "8px" }, children: gatewayUnavailable
|
|
62
|
+
? t("publishNeedsGateway")
|
|
63
|
+
: t("containerNotRunning") })), _jsxs("div", { style: { ...rowStyle, paddingTop: "8px" }, children: [_jsx(Input, { type: "number", min: MIN_PORT, max: MAX_PORT, value: port, disabled: !canPublish, placeholder: t("podPort"), onChange: (event) => setPort(event.target.value), onKeyDown: (event) => {
|
|
64
|
+
if (event.key === "Enter")
|
|
65
|
+
submit();
|
|
66
|
+
}, style: { width: "140px" } }), _jsx(Input, { type: "number", min: MIN_HOST_PORT, max: MAX_HOST_PORT, value: hostPort, disabled: !canPublish, placeholder: t("hostPortOptional"), onChange: (event) => setHostPort(event.target.value), onKeyDown: (event) => {
|
|
67
|
+
if (event.key === "Enter")
|
|
68
|
+
submit();
|
|
69
|
+
}, style: { width: "200px" } }), _jsx(Button, { variant: "outline", size: "sm", disabled: !canPublish || podPort === undefined || hostPortInvalid, onClick: submit, children: t("publishPort") })] }), port !== "" && podPort === undefined
|
|
70
|
+
? _jsx("p", { style: { ...hint, margin: 0 }, children: t("invalidPort") })
|
|
71
|
+
: null, hostPortInvalid
|
|
72
|
+
? _jsx("p", { style: { ...hint, margin: 0 }, children: t("invalidHostPort") })
|
|
73
|
+
: null] }));
|
|
74
|
+
}
|
|
@@ -27,6 +27,9 @@ export declare function ContainerRow(props: {
|
|
|
27
27
|
onSetContainerPaths: (workspace: string, container: string, paths: readonly string[]) => void;
|
|
28
28
|
onAddContainerSecret: (workspace: string, container: string, envVar: string, secret: string) => void;
|
|
29
29
|
onRemoveContainerSecret: (workspace: string, container: string, envVar: string) => void;
|
|
30
|
+
onPublishContainerPort: (workspace: string, container: string, port: number, suggestedHostPort?: number) => void;
|
|
31
|
+
onUnpublishContainerPort: (workspace: string, container: string, port: number, protocol: string) => void;
|
|
32
|
+
gatewayUnavailable: boolean;
|
|
30
33
|
projectName: string;
|
|
31
34
|
projectsRoot: string;
|
|
32
35
|
directoryPicker?: DirectoryPickerFace;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { EnvEditor, MountsEditor } from "./container-card-editors.js";
|
|
3
3
|
import { PathsEditor } from "./container-card-paths.js";
|
|
4
|
+
import { PortsEditor } from "./container-card-ports.js";
|
|
4
5
|
import { ConfirmButton, mountKindShort, mountViewToInput, } from "./container-card-shared.js";
|
|
5
6
|
import { actions, containerHeader, containerRow, greyId, imageSelect, tableStyle, tdStyle, thStyle, wsBody, } from "./container-card-styles.js";
|
|
6
7
|
import { Button, DisclosureRow, Input, Pill, } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
@@ -42,7 +43,7 @@ export function mountSummaries(mounts) {
|
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
export function ContainerRow(props) {
|
|
45
|
-
const { t, container, images, volumes, secrets, busy, onRemove, onRecreate, onAddContainerMount, onRemoveContainerMount, onUpdateContainerMount, onSetContainerPaths, onAddContainerSecret, onRemoveContainerSecret, projectName, projectsRoot, directoryPicker, } = props;
|
|
46
|
+
const { t, container, images, volumes, secrets, busy, onRemove, onRecreate, onAddContainerMount, onRemoveContainerMount, onUpdateContainerMount, onSetContainerPaths, onAddContainerSecret, onRemoveContainerSecret, onPublishContainerPort, onUnpublishContainerPort, gatewayUnavailable, projectName, projectsRoot, directoryPicker, } = props;
|
|
46
47
|
const [selected, setSelected] = useState(container.imageId);
|
|
47
48
|
const [env, setEnv] = useState(container.env);
|
|
48
49
|
// The row is keyed by container name, so it survives a snapshot refresh.
|
|
@@ -61,9 +62,14 @@ export function ContainerRow(props) {
|
|
|
61
62
|
const [mountOpen, setMountOpen] = useState(false);
|
|
62
63
|
const [pathOpen, setPathOpen] = useState(false);
|
|
63
64
|
const [secretOpen, setSecretOpen] = useState(false);
|
|
65
|
+
const [portOpen, setPortOpen] = useState(false);
|
|
64
66
|
const [attachSecret, setAttachSecret] = useState("");
|
|
65
67
|
const [attachVar, setAttachVar] = useState("");
|
|
66
68
|
const enabled = container.workspaceSlug !== "" && !busy;
|
|
69
|
+
// Publishing needs a live guest agent to create the forwarding socket, and a
|
|
70
|
+
// running gateway to bind the host port; the editor reflects both.
|
|
71
|
+
const canPublish = enabled && container.status === "running" &&
|
|
72
|
+
!gatewayUnavailable;
|
|
67
73
|
const mountRows = mountSummaries(container.mounts);
|
|
68
74
|
const envEntries = Object.entries(container.env);
|
|
69
75
|
const secretEntries = Object.entries(container.secretEnv);
|
|
@@ -80,6 +86,10 @@ export function ContainerRow(props) {
|
|
|
80
86
|
? (_jsxs("tr", { children: [_jsx("th", { style: thStyle, scope: "row", children: t("secretEnv") }), _jsx("td", { style: tdStyle, children: secretEntries
|
|
81
87
|
.map(([envVar, secretName]) => `${envVar}=${secretName}`)
|
|
82
88
|
.join(", ") })] }))
|
|
89
|
+
: null, container.publishedPorts.length > 0
|
|
90
|
+
? (_jsxs("tr", { children: [_jsx("th", { style: thStyle, scope: "row", children: t("portsTitle") }), _jsx("td", { style: tdStyle, children: container.publishedPorts
|
|
91
|
+
.map((published) => `${published.port}/${published.protocol} → ${published.endpoint}`)
|
|
92
|
+
.join(", ") })] }))
|
|
83
93
|
: null] }) }), _jsxs("div", { style: actions, children: [_jsx(ConfirmButton, { t: t, label: t("remove"), title: t("confirmTitle"), description: t("confirmRemoveContainer", {
|
|
84
94
|
workspace: projectName,
|
|
85
95
|
container: container.containerName,
|
|
@@ -118,6 +128,6 @@ export function ContainerRow(props) {
|
|
|
118
128
|
if (event.key === "Enter")
|
|
119
129
|
attach();
|
|
120
130
|
}, style: { width: "200px" } }), _jsx(Button, { variant: "outline", size: "sm", disabled: !enabled || attachVar.trim() === "" ||
|
|
121
|
-
attachSecret === "", onClick: attach, children: t("attachSecret") })] })] }) })] }));
|
|
131
|
+
attachSecret === "", onClick: attach, children: t("attachSecret") })] })] }) }), _jsx(DisclosureRow, { icon: _jsx("span", {}), title: t("portsTitle"), open: portOpen, expandable: true, onToggle: () => setPortOpen(!portOpen), children: _jsx("div", { style: wsBody, children: _jsx(PortsEditor, { t: t, ports: container.publishedPorts, busy: busy, enabled: enabled, canPublish: canPublish, gatewayUnavailable: gatewayUnavailable, onPublish: (port, suggestedHostPort) => onPublishContainerPort(container.workspaceSlug, container.containerName, port, suggestedHostPort), onUnpublish: (port, protocol) => onUnpublishContainerPort(container.workspaceSlug, container.containerName, port, protocol) }) }) })] }));
|
|
122
132
|
}
|
|
123
133
|
export { CreateContainerModal } from "./container-card-create-modal.js";
|
|
@@ -28,6 +28,9 @@ export declare function WorkspaceSection(props: {
|
|
|
28
28
|
onSetContainerPaths: (workspace: string, container: string, paths: readonly string[]) => void;
|
|
29
29
|
onAddContainerSecret: (workspace: string, container: string, envVar: string, secret: string) => void;
|
|
30
30
|
onRemoveContainerSecret: (workspace: string, container: string, envVar: string) => void;
|
|
31
|
+
onPublishContainerPort: (workspace: string, container: string, port: number, suggestedHostPort?: number) => void;
|
|
32
|
+
onUnpublishContainerPort: (workspace: string, container: string, port: number, protocol: string) => void;
|
|
33
|
+
gatewayUnavailable: boolean;
|
|
31
34
|
onSyncDefaults: (workspace: string) => void;
|
|
32
35
|
defaultEnvCount: number;
|
|
33
36
|
}): ReactNode;
|
|
@@ -8,7 +8,7 @@ import { greyId, hint, wsBody } from "./container-card-styles.js";
|
|
|
8
8
|
import { Button, DisclosureRow, StateDot, } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
9
9
|
import { useState } from "react";
|
|
10
10
|
export function WorkspaceSection(props) {
|
|
11
|
-
const { t, workspace, containers, images, volumes, secrets, busy, defaultImage, projectsRoot, directoryPicker, onRemove, onRemoveWorkspace, onRecreate, onCreate, onStartContainer, onAddContainerMount, onRemoveContainerMount, onUpdateContainerMount, onSetContainerPaths, onAddContainerSecret, onRemoveContainerSecret, onSyncDefaults, defaultEnvCount, } = props;
|
|
11
|
+
const { t, workspace, containers, images, volumes, secrets, busy, defaultImage, projectsRoot, directoryPicker, onRemove, onRemoveWorkspace, onRecreate, onCreate, onStartContainer, onAddContainerMount, onRemoveContainerMount, onUpdateContainerMount, onSetContainerPaths, onAddContainerSecret, onRemoveContainerSecret, onPublishContainerPort, onUnpublishContainerPort, gatewayUnavailable, onSyncDefaults, defaultEnvCount, } = props;
|
|
12
12
|
const [open, setOpen] = useState(false);
|
|
13
13
|
const [createOpen, setCreateOpen] = useState(null);
|
|
14
14
|
const hasContainer = containers.length > 0;
|
|
@@ -16,7 +16,7 @@ export function WorkspaceSection(props) {
|
|
|
16
16
|
? _jsx(StateDot, { state: containerStateDot(containers[0]?.status ?? "") })
|
|
17
17
|
: _jsx("span", {}), title: workspace.projectName, open: open, expandable: true, onToggle: () => setOpen(!open), children: [_jsxs("div", { style: wsBody, children: [_jsx("code", { style: greyId, children: workspace.workspaceSlug }), !hasContainer
|
|
18
18
|
? (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [_jsx("p", { style: { ...hint, margin: 0 }, children: t("noContainers") }), _jsx("div", { children: _jsx(Button, { variant: "outline", size: "sm", disabled: busy, onClick: () => setCreateOpen("default"), children: t("createContainer") }) })] }))
|
|
19
|
-
: (_jsxs(_Fragment, { children: [containers.map((container) => (_jsx(ContainerRow, { t: t, container: container, images: images, volumes: volumes, secrets: secrets, busy: busy, onRemove: onRemove, onRecreate: onRecreate, onAddContainerMount: onAddContainerMount, onRemoveContainerMount: onRemoveContainerMount, onUpdateContainerMount: onUpdateContainerMount, onSetContainerPaths: onSetContainerPaths, projectName: workspace.projectName, projectsRoot: projectsRoot, directoryPicker: directoryPicker, onAddContainerSecret: onAddContainerSecret, onRemoveContainerSecret: onRemoveContainerSecret }, container.containerName))), _jsx("div", { children: _jsx(Button, { variant: "outline", size: "sm", disabled: busy, onClick: () => setCreateOpen("named"), children: t("addContainer") }) })] })), _jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: [_jsx(ConfirmButton, { t: t, label: t("applyDefaults"), title: t("confirmTitle"), description: t("confirmApplyDefaults"), disabled: busy || defaultEnvCount === 0, onConfirm: () => onSyncDefaults(workspace.workspaceSlug) }), _jsx(ConfirmButton, { t: t, label: t("removePod"), title: t("confirmTitle"), description: t("confirmRemovePod", {
|
|
19
|
+
: (_jsxs(_Fragment, { children: [containers.map((container) => (_jsx(ContainerRow, { t: t, container: container, images: images, volumes: volumes, secrets: secrets, busy: busy, onRemove: onRemove, onRecreate: onRecreate, onAddContainerMount: onAddContainerMount, onRemoveContainerMount: onRemoveContainerMount, onUpdateContainerMount: onUpdateContainerMount, onSetContainerPaths: onSetContainerPaths, projectName: workspace.projectName, projectsRoot: projectsRoot, directoryPicker: directoryPicker, onAddContainerSecret: onAddContainerSecret, onRemoveContainerSecret: onRemoveContainerSecret, onPublishContainerPort: onPublishContainerPort, onUnpublishContainerPort: onUnpublishContainerPort, gatewayUnavailable: gatewayUnavailable }, container.containerName))), _jsx("div", { children: _jsx(Button, { variant: "outline", size: "sm", disabled: busy, onClick: () => setCreateOpen("named"), children: t("addContainer") }) })] })), _jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: [_jsx(ConfirmButton, { t: t, label: t("applyDefaults"), title: t("confirmTitle"), description: t("confirmApplyDefaults"), disabled: busy || defaultEnvCount === 0, onConfirm: () => onSyncDefaults(workspace.workspaceSlug) }), _jsx(ConfirmButton, { t: t, label: t("removePod"), title: t("confirmTitle"), description: t("confirmRemovePod", {
|
|
20
20
|
workspace: workspace.projectName,
|
|
21
21
|
}), disabled: busy, onConfirm: () => onRemoveWorkspace(workspace.workspaceSlug) })] })] }), _jsx(CreateContainerModal, { t: t, workspace: workspace, images: images, volumes: volumes, secrets: secrets, busy: busy, defaultImage: defaultImage, projectsRoot: projectsRoot, directoryPicker: directoryPicker, named: createOpen === "named", existing: containers.map((container) => container.containerName), open: createOpen !== null, onClose: () => setCreateOpen(null), onCreate: (container, config) => {
|
|
22
22
|
if (createOpen === "named") {
|