Skip to content

Commit

Permalink
disable websocket attach for now
Browse files Browse the repository at this point in the history
  • Loading branch information
sepbot committed Nov 23, 2024
1 parent e3ce006 commit b90653b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.env
.envrc
.npmrc
.vscode
*.tsbuildinfo
*.tgz
*.zip
Expand Down
3 changes: 1 addition & 2 deletions generator/fixes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export function applyFixes(schema) {

// it is not possible to infer that this endpoint returns a stream
schema.paths["/images/create"].post.chunked = true;

//
schema.paths["/containers/{id}/logs"].get.chunked = true;
schema.paths["/containers/{id}/attach/ws"].get.websocket = true;

for (const path in schema.paths) {
for (const endpoint in schema.paths[path]) {
Expand Down
11 changes: 9 additions & 2 deletions generator/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ async function main() {
const output = {
errors: [],
stream: outputStream && !props.chunked,
websocket: false,
websocket: props.websocket === true,
upgrade: false,
empty: false,
noChange: false,
chunked: props.chunked || (responses["101"] === undefined && outputStream),
Expand All @@ -78,7 +79,7 @@ async function main() {
const code = parseInt(codeStr);

if (code === 101) {
output.websocket = true;
output.upgrade = true;
}

else if (code === 200 || code === 201) {
Expand Down Expand Up @@ -157,10 +158,16 @@ async function main() {
method: props.method,
path: props.path,
chunked: props.output.chunked,
websocket: props.output.websocket,
upgrade: props.output.stream,
path_has_params: props.path.includes("{") && props.path.includes("}"),
};

if (attribs.websocket) {
// TODO: not sure how to support websocket, container exits as soon as we attach
continue;
}

if ("input" in props) {
attribs.input_name = `${name}Input`;
attribs.input_type = jsonSchemaToZod(props.input);
Expand Down
8 changes: 8 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
doit:
pnpm run generate && \
pnpm run test && \
pnpm run build # dist files interfere with jest

bump-version level:
#!/bin/bash

Expand All @@ -23,3 +28,6 @@ create-release:
--verify-tag \
--title "${version}" \
--repo manualpilot/docker-client-ts

reverse-proxy:
caddy reverse-proxy --from http://localhost:8888 --to unix//var/run/docker.sock
6 changes: 2 additions & 4 deletions static/etc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ export function chunked(resp: Dispatcher.ResponseData): Observable<string> {
return stream.asObservable();
}

export type TerminalSession = {
// write commands to this stream
export type CombinedTerminalSession = {
input: ReplaySubject<string>;
// combined stdout/stderr output will through on this stream
output: ReplaySubject<string>;
close: () => void;
};

// WARN: this doesn't handle TTY mode yet
export function terminal(resp: Dispatcher.UpgradeData): TerminalSession {
export function terminal(resp: Dispatcher.UpgradeData): CombinedTerminalSession {
const input = new ReplaySubject<string>(30);
const output = new ReplaySubject<string>(30);

Expand Down
4 changes: 2 additions & 2 deletions templates/tag.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Pool } from "undici";
import { Observable } from "rxjs";
import type { Observable } from "rxjs";
import type { Pool } from "undici";
import { z } from "zod";
import { chunked, sub, terminal } from "~/etc";

Expand Down

0 comments on commit b90653b

Please sign in to comment.