@zukhruf/docker 0.8.16 → 0.8.17
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 +45 -1
- package/dist/docker.d.ts +3 -1
- package/dist/docker.d.ts.map +1 -1
- package/dist/docker.js +1 -1
- package/dist/docker.js.map +1 -1
- package/dist/ssh-connection.d.ts +8 -3
- package/dist/ssh-connection.d.ts.map +1 -1
- package/dist/ssh-connection.js +20 -8
- package/dist/ssh-connection.js.map +1 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +7 -6
- package/dist/transport.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -484,10 +484,52 @@ await spawn(
|
|
|
484
484
|
|
|
485
485
|
## SSH engines
|
|
486
486
|
|
|
487
|
-
For an `ssh://` host, the connection helper is
|
|
487
|
+
For an `ssh://` host, the connection helper is this command ([ADR 0010](./docs/adr/0010-ssh-gets-the-options-of-the-docker-cli-and-the-flags-of-the-caller.md)):
|
|
488
|
+
|
|
489
|
+
```sh
|
|
490
|
+
ssh <sshFlags> -T -o BatchMode=yes -o ConnectTimeout=30 -l <user> -p <port> -- <machine> docker system dial-stdio
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
`-l` and `-p` are there only when the host has a user and a port. `-T`, `-l`, `-p` and `-o ConnectTimeout=30` are the options that the Docker CLI sends. `-o BatchMode=yes` is an option of the package: the Docker CLI does not send it. The package sends no keepalive.
|
|
494
|
+
|
|
495
|
+
`ssh` reads `~/.ssh/config`, so jump hosts, keys, agents and connection sharing work as they work for the CLI. The remote machine must have `docker` on the `PATH` of its SSH shell.
|
|
488
496
|
|
|
489
497
|
Each connection of the client is one `ssh` process. The client keeps idle connections for the next request. An attach, an exec, followed logs and events each use their own connection. Disposal of the client ends the `ssh` processes.
|
|
490
498
|
|
|
499
|
+
### Give flags to ssh
|
|
500
|
+
|
|
501
|
+
`sshFlags` are raw flags for `ssh`. Only an engine at an `ssh://` host uses them, also when a context or `DOCKER_HOST` selected that host. An engine at a `unix://` or `npipe://` host ignores them.
|
|
502
|
+
|
|
503
|
+
```ts
|
|
504
|
+
await using remote = await Docker.connect({
|
|
505
|
+
clock: globalThis,
|
|
506
|
+
host: 'ssh://root@box',
|
|
507
|
+
sshFlags: ['-o', 'ServerAliveInterval=10', '-o', 'ServerAliveCountMax=2'],
|
|
508
|
+
});
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
The flags come first on the command line. OpenSSH uses the first value that it gets for each option, so a flag of the caller wins over an option of the package, and over `~/.ssh/config`. When the flags name `ConnectTimeout`, the package does not send `-o ConnectTimeout=30`. This is the rule of the Docker CLI: `['-o', 'ConnectTimeout=5']` and `['-oConnectTimeout=5']` both name it.
|
|
512
|
+
|
|
513
|
+
### End a dead connection
|
|
514
|
+
|
|
515
|
+
`ConnectTimeout` is a limit for the start of a connection only: the connect, the SSH handshake and the key exchange. No call has a time limit after that.
|
|
516
|
+
|
|
517
|
+
Without a keepalive, a connection to a machine that stops answering hangs the call, as it hangs the Docker CLI. The call ends only when its signal aborts.
|
|
518
|
+
|
|
519
|
+
With a keepalive, `ssh` exits with 255 when the machine stops answering. A call that waits for its answer rejects with `ConnectionFailedError`, and its `cause` has the exit code and the standard error of `ssh`. An open stream, such as followed logs or events, rejects with an error whose `cause` has the same exit code and standard error.
|
|
520
|
+
|
|
521
|
+
Set the keepalive in `~/.ssh/config`:
|
|
522
|
+
|
|
523
|
+
```
|
|
524
|
+
Host box
|
|
525
|
+
ServerAliveInterval 10
|
|
526
|
+
ServerAliveCountMax 2
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
Or give the same options in `sshFlags`, as in the example above.
|
|
530
|
+
|
|
531
|
+
With connection sharing (`ControlMaster`), the settings of the master connection apply. The flags of a later `ssh` do not.
|
|
532
|
+
|
|
491
533
|
## The API version
|
|
492
534
|
|
|
493
535
|
The path of each request starts with the API version, as in `/v1.51/containers/json`. `Docker.connect()` reads the highest version of the engine from `GET /_ping`. The client then uses the lower of that version and its own highest version. It refuses an engine that is older than its own lowest version with `UnsupportedEngineError`. `docker.apiVersion` gives the version that the client uses.
|
|
@@ -561,6 +603,8 @@ export type ConnectOptions = CancelOptions & {
|
|
|
561
603
|
environment?: Environment;
|
|
562
604
|
/** The clock of the waits of the client, and of the time of the files that it writes: a `WallClock` of `@zukhruf/async`. Production gives `globalThis`. */
|
|
563
605
|
clock: WallClock;
|
|
606
|
+
/** Raw flags for `ssh`. Only an engine at an `ssh://` host uses them. */
|
|
607
|
+
sshFlags?: readonly string[];
|
|
564
608
|
} & ({ context?: string; host?: never } | { host?: string; context?: never });
|
|
565
609
|
|
|
566
610
|
export interface DockerContext {
|
package/dist/docker.d.ts
CHANGED
|
@@ -8,11 +8,13 @@ import type { CancelOptions, Filters } from './options.ts';
|
|
|
8
8
|
import { Volumes } from './volumes.ts';
|
|
9
9
|
/**
|
|
10
10
|
* A context or a host, never both. `clock` is the clock of the waits of the
|
|
11
|
-
* client: `globalThis` in production, a fake clock in a test.
|
|
11
|
+
* client: `globalThis` in production, a fake clock in a test. `sshFlags` are
|
|
12
|
+
* raw flags for `ssh`: only an engine at an ssh:// host uses them.
|
|
12
13
|
*/
|
|
13
14
|
export type ConnectOptions = CancelOptions & {
|
|
14
15
|
environment?: Environment;
|
|
15
16
|
clock: WallClock;
|
|
17
|
+
sshFlags?: readonly string[];
|
|
16
18
|
} & ({
|
|
17
19
|
context?: string;
|
|
18
20
|
host?: never;
|
package/dist/docker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../src/docker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAGjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO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CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uFAAuF;IACvF,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAGxB,OAAO;IAqBP,kGAAkG;WACrF,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IA6B9D,kEAAkE;WACrD,QAAQ,CACnB,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,WAAW,CAAA;KAAO,GAC1C,OAAO,CAAC,aAAa,EAAE,CAAC;IAIrB,IAAI,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC;IAItE;;;;OAIG;IACI,MAAM,CACX,OAAO,GAAE,aAAa,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,GAClE,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC;IAWxC;;;;;;OAMG;IACG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7C"}
|
package/dist/docker.js
CHANGED
|
@@ -45,7 +45,7 @@ export class Docker {
|
|
|
45
45
|
const engine = await selectEngine(options);
|
|
46
46
|
const parsed = parseHost(engine.host);
|
|
47
47
|
const transport = parsed.kind === 'ssh'
|
|
48
|
-
? new SshTransport(parsed.url)
|
|
48
|
+
? new SshTransport(parsed.url, options.sshFlags ?? [])
|
|
49
49
|
: new SocketTransport(parsed.kind, parsed.socketPath);
|
|
50
50
|
try {
|
|
51
51
|
const unversioned = new EngineClient(engine.host, transport);
|
package/dist/docker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../src/docker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAGL,YAAY,EACZ,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../src/docker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAGL,YAAY,EACZ,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,M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;IACH,CAAC;IAED,kEAAkE;IAClE,MAAM,CAAC,KAAK,CAAC,QAAQ,CACnB,UAAyC,EAAE;QAE3C,OAAO,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,UAAyB,EAAE;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAuB,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,CAAC,MAAM,CACX,UAAiE,EAAE;QAEnE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE;YAC3D,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;YACzB,MAAM;SACP,CAAC,CAAC;QACH,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3C,IAAI,cAAc,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;QACzC,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/ssh-connection.d.ts
CHANGED
|
@@ -9,12 +9,17 @@ export declare class SshExitError extends Error {
|
|
|
9
9
|
readonly stderr: string;
|
|
10
10
|
constructor(exitCode: number | null, signal: NodeJS.Signals | null, stderr: string);
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The arguments of the connection helper. `-T`, `-l`, `-p` and the connect
|
|
14
|
+
* timeout are as the connhelper of docker/cli gives them; `BatchMode=yes` is
|
|
15
|
+
* an option of this package. The flags of the caller come first, because
|
|
16
|
+
* `ssh` uses the first value that it gets for an option.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sshArguments(url: URL, sshFlags: readonly string[]): string[];
|
|
14
19
|
/** The connections to an engine at an ssh:// host. Each connection is one `ssh` process. */
|
|
15
20
|
export declare class SshTransport implements Transport {
|
|
16
21
|
#private;
|
|
17
|
-
constructor(url: URL);
|
|
22
|
+
constructor(url: URL, sshFlags: readonly string[]);
|
|
18
23
|
request(options: RequestOptions): ClientRequest;
|
|
19
24
|
/** Ends the standard input of `ssh`: `docker system dial-stdio` then closes the write side to the engine. */
|
|
20
25
|
endInput(socket: Duplex): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-connection.d.ts","sourceRoot":"","sources":["../src/ssh-connection.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKhD,2FAA2F;AAC3F,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACvC,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGtB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAC7B,MAAM,EAAE,MAAM;CAUjB;AAED
|
|
1
|
+
{"version":3,"file":"ssh-connection.d.ts","sourceRoot":"","sources":["../src/ssh-connection.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKhD,2FAA2F;AAC3F,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACvC,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGtB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,EAC7B,MAAM,EAAE,MAAM;CAUjB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAmB5E;AA8LD,4FAA4F;AAC5F,qBAAa,YAAa,YAAW,SAAS;;gBAGhC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE;IAIjD,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa;IAI/C,6GAA6G;IAC7G,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI9B,gEAAgE;IAChE,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
package/dist/ssh-connection.js
CHANGED
|
@@ -19,12 +19,22 @@ export class SshExitError extends Error {
|
|
|
19
19
|
this.stderr = stderr;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The arguments of the connection helper. `-T`, `-l`, `-p` and the connect
|
|
24
|
+
* timeout are as the connhelper of docker/cli gives them; `BatchMode=yes` is
|
|
25
|
+
* an option of this package. The flags of the caller come first, because
|
|
26
|
+
* `ssh` uses the first value that it gets for an option.
|
|
27
|
+
*/
|
|
28
|
+
export function sshArguments(url, sshFlags) {
|
|
24
29
|
return [
|
|
30
|
+
...sshFlags,
|
|
25
31
|
'-T',
|
|
26
32
|
'-o',
|
|
27
33
|
'BatchMode=yes',
|
|
34
|
+
// The rule of addSSHTimeout of docker/cli: the flags, joined, name the option.
|
|
35
|
+
...(sshFlags.join('').includes('ConnectTimeout')
|
|
36
|
+
? []
|
|
37
|
+
: ['-o', 'ConnectTimeout=30']),
|
|
28
38
|
...(url.username ? ['-l', decodeURIComponent(url.username)] : []),
|
|
29
39
|
...(url.port ? ['-p', url.port] : []),
|
|
30
40
|
'--',
|
|
@@ -49,9 +59,9 @@ class SshConnection extends Duplex {
|
|
|
49
59
|
#stderr = '';
|
|
50
60
|
/** Resolves when `ssh` exited and its pipes are closed. */
|
|
51
61
|
exited;
|
|
52
|
-
constructor(url) {
|
|
62
|
+
constructor(url, sshFlags) {
|
|
53
63
|
super({ allowHalfOpen: true });
|
|
54
|
-
const child = spawn('ssh', sshArguments(url), {
|
|
64
|
+
const child = spawn('ssh', sshArguments(url, sshFlags), {
|
|
55
65
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
56
66
|
});
|
|
57
67
|
this.#child = child;
|
|
@@ -161,13 +171,15 @@ class SshConnection extends Duplex {
|
|
|
161
171
|
*/
|
|
162
172
|
class SshAgent extends Agent {
|
|
163
173
|
#url;
|
|
174
|
+
#sshFlags;
|
|
164
175
|
#connections = new Set();
|
|
165
|
-
constructor(url) {
|
|
176
|
+
constructor(url, sshFlags) {
|
|
166
177
|
super({ keepAlive: true });
|
|
167
178
|
this.#url = url;
|
|
179
|
+
this.#sshFlags = sshFlags;
|
|
168
180
|
}
|
|
169
181
|
createConnection() {
|
|
170
|
-
const connection = new SshConnection(this.#url);
|
|
182
|
+
const connection = new SshConnection(this.#url, this.#sshFlags);
|
|
171
183
|
this.#connections.add(connection);
|
|
172
184
|
void connection.exited().then(() => {
|
|
173
185
|
this.#connections.delete(connection);
|
|
@@ -208,8 +220,8 @@ class SshAgent extends Agent {
|
|
|
208
220
|
/** The connections to an engine at an ssh:// host. Each connection is one `ssh` process. */
|
|
209
221
|
export class SshTransport {
|
|
210
222
|
#agent;
|
|
211
|
-
constructor(url) {
|
|
212
|
-
this.#agent = new SshAgent(url);
|
|
223
|
+
constructor(url, sshFlags) {
|
|
224
|
+
this.#agent = new SshAgent(url, sshFlags);
|
|
213
225
|
}
|
|
214
226
|
request(options) {
|
|
215
227
|
return request({ ...options, agent: this.#agent });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-connection.js","sourceRoot":"","sources":["../src/ssh-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EACL,KAAK,EAGL,OAAO,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,yFAAyF;AACzF,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,2FAA2F;AAC3F,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,QAAQ,CAAgB;IACxB,MAAM,CAAwB;IACvC,6FAA6F;IACpF,MAAM,CAAS;IAExB,YACE,QAAuB,EACvB,MAA6B,EAC7B,MAAc;QAEd,KAAK,CACH,mBAAmB,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,QAAQ,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAC9H,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ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
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,iDAAiD;AACjD,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAAC;IAChD,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gGAAgG;IAChG,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oFAAoF;IACpF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,SAAS;;gBAOnC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,UAAU,EAAE,MAAM;IAKtD,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa;IAiB/C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK9B,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI3B,8FAA8F;IACxF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAiB7B"}
|
package/dist/transport.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { once } from 'node:events';
|
|
2
1
|
import { Agent, request, } from 'node:http';
|
|
3
2
|
import { Socket } from 'node:net';
|
|
4
3
|
/**
|
|
@@ -50,12 +49,14 @@ export class SocketTransport {
|
|
|
50
49
|
async close() {
|
|
51
50
|
const sockets = [...this.#sockets];
|
|
52
51
|
this.#agent.destroy();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
// A socket in the set has not emitted 'close', also when it is destroyed:
|
|
53
|
+
// `closed` of a destroyed net.Socket is true before the event. The wait
|
|
54
|
+
// is not once() of node:events, which rejects on the 'error' of a socket
|
|
55
|
+
// that the client destroyed with the error of the disposal.
|
|
56
|
+
await Promise.all(sockets.map((socket) => {
|
|
57
|
+
const closed = new Promise((resolve) => socket.once('close', () => resolve()));
|
|
57
58
|
socket.destroy();
|
|
58
|
-
|
|
59
|
+
return closed;
|
|
59
60
|
}));
|
|
60
61
|
}
|
|
61
62
|
}
|
package/dist/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAGL,OAAO,GACR,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAclC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IACjB,KAAK,CAAmB;IACxB,WAAW,CAAS;IACpB,MAAM,GAAG,IAAI,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,sFAAsF;IAC7E,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,YAAY,IAAsB,EAAE,UAAkB;QACpD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,OAAuB;QAC7B,MAAM,IAAI,GAAG,OAAO,CAAC;YACnB,GAAG,OAAO;YACV,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,UAAU,EAAE,IAAI,CAAC,WAAW;SAC7B,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IA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AC;QAChB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/docker",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.17",
|
|
4
4
|
"description": "A client for the Docker Engine API on Node.js. It selects the engine that the Docker CLI selects, and it sends HTTP requests to that engine through a Unix socket, a Windows named pipe or SSH, with no Docker CLI and no third-party dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@zukhruf/async": "^0.8.
|
|
43
|
+
"@zukhruf/async": "^0.8.17"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@sinonjs/fake-timers": "15.4.0"
|