@norskvideo/ctl-dev-kit 0.1.35 → 0.1.36
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.
|
@@ -104,6 +104,11 @@ jobs:
|
|
|
104
104
|
# reaches host-published ports via the host-gateway alias, not
|
|
105
105
|
# localhost — same as the integration suite.
|
|
106
106
|
NORSK_TEST_HOST: host.docker.internal
|
|
107
|
+
# Reach launched instances over norsk-net by service DNS (as the
|
|
108
|
+
# integration tier already does) AND, on a ctl that supports it, launch
|
|
109
|
+
# them binding no host ports — so concurrent doc-guide instances can't
|
|
110
|
+
# collide on the product's deterministic host-port bands.
|
|
111
|
+
NORSK_TEST_NET: direct
|
|
107
112
|
run: |
|
|
108
113
|
nix develop .#build --command bash -c '
|
|
109
114
|
set -euo pipefail
|
|
@@ -13,4 +13,13 @@ export declare function startInstanceProxy(opts: {
|
|
|
13
13
|
studioHostPort: number;
|
|
14
14
|
instanceId: string;
|
|
15
15
|
dashboardKey: string;
|
|
16
|
+
/** Explicit upstream studio endpoint. When set, the proxy forwards here
|
|
17
|
+
* instead of `NORSK_TEST_HOST:studioHostPort` — a `noPublish` instance binds
|
|
18
|
+
* no host port, so the caller supplies its `norsk-net` reach
|
|
19
|
+
* (`<id>-studio-1:8000`) via `resolveEndpoint`. Omitted = today's
|
|
20
|
+
* host-published behaviour. */
|
|
21
|
+
upstream?: {
|
|
22
|
+
host: string;
|
|
23
|
+
port: number;
|
|
24
|
+
};
|
|
16
25
|
}): InstanceProxy;
|
|
@@ -27,8 +27,10 @@ export function startInstanceProxy(opts) {
|
|
|
27
27
|
// (host.docker.internal), mirroring @norskvideo/ctl-test-harness's STUDIO_HOST.
|
|
28
28
|
// Without this the proxy's own fetch/WebSocket dials localhost inside the
|
|
29
29
|
// runner container and ConnectionRefuses, so the baked dashboard never loads.
|
|
30
|
-
|
|
31
|
-
const
|
|
30
|
+
// An explicit `upstream` (direct/noPublish mode) overrides both.
|
|
31
|
+
const upstreamHost = opts.upstream?.host ?? process.env.NORSK_TEST_HOST ?? "localhost";
|
|
32
|
+
const upstreamPort = opts.upstream?.port ?? opts.studioHostPort;
|
|
33
|
+
const httpUpstream = `http://${upstreamHost}:${upstreamPort}`;
|
|
32
34
|
const strip = (pathname) => pathname === prefix ? "/" : pathname.startsWith(`${prefix}/`) ? pathname.slice(prefix.length) : pathname;
|
|
33
35
|
const server = Bun.serve({
|
|
34
36
|
port: 0,
|
|
@@ -36,7 +38,7 @@ export function startInstanceProxy(opts) {
|
|
|
36
38
|
const u = new URL(req.url);
|
|
37
39
|
const path = strip(u.pathname);
|
|
38
40
|
if (req.headers.get("upgrade")?.toLowerCase() === "websocket") {
|
|
39
|
-
const upstreamUrl = `ws://${upstreamHost}:${
|
|
41
|
+
const upstreamUrl = `ws://${upstreamHost}:${upstreamPort}${path}${u.search}`;
|
|
40
42
|
const ok = srv.upgrade(req, { data: { upstreamUrl, upstream: null, queue: [] } });
|
|
41
43
|
return ok ? undefined : new Response("ws upgrade failed", { status: 400 });
|
|
42
44
|
}
|