@zukhruf/docker 0.0.0-stage → 0.3.33
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/LICENSE +21 -0
- package/README.md +888 -2
- package/dist/api-version.d.ts +7 -0
- package/dist/api-version.d.ts.map +1 -0
- package/dist/api-version.js +22 -0
- package/dist/api-version.js.map +1 -0
- package/dist/context-store.d.ts +22 -0
- package/dist/context-store.d.ts.map +1 -0
- package/dist/context-store.js +128 -0
- package/dist/context-store.js.map +1 -0
- package/dist/docker.d.ts +34 -0
- package/dist/docker.d.ts.map +1 -0
- package/dist/docker.js +60 -0
- package/dist/docker.js.map +1 -0
- package/dist/engine-api.d.ts +21 -0
- package/dist/engine-api.d.ts.map +1 -0
- package/dist/engine-api.js +4 -0
- package/dist/engine-api.js.map +1 -0
- package/dist/engine-client.d.ts +26 -0
- package/dist/engine-client.d.ts.map +1 -0
- package/dist/engine-client.js +117 -0
- package/dist/engine-client.js.map +1 -0
- package/dist/errors.d.ts +43 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +64 -0
- package/dist/errors.js.map +1 -0
- package/dist/host.d.ts +13 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +22 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +7 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +2 -0
- package/dist/options.js.map +1 -0
- package/dist/ssh-connection.d.ts +20 -0
- package/dist/ssh-connection.d.ts.map +1 -0
- package/dist/ssh-connection.js +189 -0
- package/dist/ssh-connection.js.map +1 -0
- package/dist/transport.d.ts +19 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +24 -0
- package/dist/transport.js.map +1 -0
- package/package.json +40 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,CAAC;AAE5C,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAalD"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UnsupportedHostError } from "./errors.js";
|
|
2
|
+
/** Parses a unix://, npipe:// or ssh:// host. Each other host is an UnsupportedHostError. */
|
|
3
|
+
export function parseHost(host) {
|
|
4
|
+
if (host.startsWith('unix://')) {
|
|
5
|
+
const socketPath = host.slice('unix://'.length);
|
|
6
|
+
if (socketPath)
|
|
7
|
+
return { kind: 'unix', host, socketPath };
|
|
8
|
+
}
|
|
9
|
+
else if (host.startsWith('npipe://')) {
|
|
10
|
+
// npipe:////./pipe/docker_engine is the pipe \\.\pipe\docker_engine.
|
|
11
|
+
const socketPath = host.slice('npipe://'.length).replaceAll('/', '\\');
|
|
12
|
+
if (socketPath)
|
|
13
|
+
return { kind: 'npipe', host, socketPath };
|
|
14
|
+
}
|
|
15
|
+
else if (host.startsWith('ssh://') && URL.canParse(host)) {
|
|
16
|
+
const url = new URL(host);
|
|
17
|
+
if (url.hostname)
|
|
18
|
+
return { kind: 'ssh', host, url };
|
|
19
|
+
}
|
|
20
|
+
throw new UnsupportedHostError(host);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=host.js.map
|
package/dist/host.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAOnD,6FAA6F;AAC7F,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,UAAU;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC5D,CAAC;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,qEAAqE;QACrE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACvE,IAAI,UAAU;YAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC7D,CAAC;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,GAAG,CAAC,QAAQ;YAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IACtD,CAAC;IACD,MAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { DockerContext, Environment } from './context-store.ts';
|
|
2
|
+
export { type ConnectOptions, Docker } from './docker.ts';
|
|
3
|
+
export { ConnectionFailedError, ContextNotFoundError, DockerEngineError, DockerError, UnsupportedEngineError, UnsupportedHostError, } from './errors.ts';
|
|
4
|
+
export type { CancelOptions, Filters } from './options.ts';
|
|
5
|
+
/** The bodies and answers of the Engine API, with the names of its reference. Types only. */
|
|
6
|
+
export type * as EngineApi from './engine-api.ts';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE3D,6FAA6F;AAC7F,YAAY,KAAK,SAAS,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface CancelOptions {
|
|
2
|
+
/** Cancels the wait for the engine. */
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
}
|
|
5
|
+
/** The filters of a list or of the events, as the Engine API takes them. */
|
|
6
|
+
export type Filters = Record<string, string[]>;
|
|
7
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,4EAA4E;AAC5E,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ClientRequest, type RequestOptions } from 'node:http';
|
|
2
|
+
import type { Transport } from './transport.ts';
|
|
3
|
+
/** `ssh` exited before the engine answered. It is the cause of a ConnectionFailedError. */
|
|
4
|
+
export declare class SshExitError extends Error {
|
|
5
|
+
readonly exitCode: number | null;
|
|
6
|
+
readonly signal: NodeJS.Signals | null;
|
|
7
|
+
/** The last 4 KB of the standard error of `ssh`, such as "Permission denied (publickey)." */
|
|
8
|
+
readonly stderr: string;
|
|
9
|
+
constructor(exitCode: number | null, signal: NodeJS.Signals | null, stderr: string);
|
|
10
|
+
}
|
|
11
|
+
/** The arguments of the connection helper, as the connhelper of docker/cli gives them. */
|
|
12
|
+
export declare function sshArguments(url: URL): string[];
|
|
13
|
+
/** The connections to an engine at an ssh:// host. Each connection is one `ssh` process. */
|
|
14
|
+
export declare class SshTransport implements Transport {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(url: URL);
|
|
17
|
+
request(options: RequestOptions): ClientRequest;
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ssh-connection.d.ts.map
|
|
@@ -0,0 +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;AAInB,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,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,CAa/C;AA4JD,4FAA4F;AAC5F,qBAAa,YAAa,YAAW,SAAS;;gBAGhC,GAAG,EAAE,GAAG;IAIpB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa;IAIzC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { Agent, request, } from 'node:http';
|
|
3
|
+
import { Socket } from 'node:net';
|
|
4
|
+
import { Duplex } from 'node:stream';
|
|
5
|
+
/** The part of the standard error of `ssh` that an SshExitError keeps: the last 4 KB. */
|
|
6
|
+
const STDERR_LIMIT = 4096;
|
|
7
|
+
/** `ssh` exited before the engine answered. It is the cause of a ConnectionFailedError. */
|
|
8
|
+
export class SshExitError extends Error {
|
|
9
|
+
exitCode;
|
|
10
|
+
signal;
|
|
11
|
+
/** The last 4 KB of the standard error of `ssh`, such as "Permission denied (publickey)." */
|
|
12
|
+
stderr;
|
|
13
|
+
constructor(exitCode, signal, stderr) {
|
|
14
|
+
super(`ssh exited with ${exitCode === null ? `signal ${signal}` : `code ${exitCode}`}${stderr.trim() ? `: ${stderr.trim()}` : '.'}`);
|
|
15
|
+
this.name = 'SshExitError';
|
|
16
|
+
this.exitCode = exitCode;
|
|
17
|
+
this.signal = signal;
|
|
18
|
+
this.stderr = stderr;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** The arguments of the connection helper, as the connhelper of docker/cli gives them. */
|
|
22
|
+
export function sshArguments(url) {
|
|
23
|
+
return [
|
|
24
|
+
'-T',
|
|
25
|
+
'-o',
|
|
26
|
+
'BatchMode=yes',
|
|
27
|
+
...(url.username ? ['-l', decodeURIComponent(url.username)] : []),
|
|
28
|
+
...(url.port ? ['-p', url.port] : []),
|
|
29
|
+
'--',
|
|
30
|
+
url.hostname,
|
|
31
|
+
'docker',
|
|
32
|
+
'system',
|
|
33
|
+
'dial-stdio',
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* One connection to an SSH engine: one `ssh` process that runs
|
|
38
|
+
* `docker system dial-stdio`. Its readable side is the standard output of
|
|
39
|
+
* `ssh`, and its writable side is the standard input of `ssh`.
|
|
40
|
+
*
|
|
41
|
+
* The end of the writable side ends the standard input of `ssh`, and
|
|
42
|
+
* `docker system dial-stdio` then closes the write side of its connection to
|
|
43
|
+
* the engine. This is the end of the input of an attach or an exec.
|
|
44
|
+
*/
|
|
45
|
+
class SshConnection extends Duplex {
|
|
46
|
+
#child;
|
|
47
|
+
#stderr = '';
|
|
48
|
+
/** Resolves when `ssh` exited and its pipes are closed. */
|
|
49
|
+
exited;
|
|
50
|
+
constructor(url) {
|
|
51
|
+
super({ allowHalfOpen: true });
|
|
52
|
+
const child = spawn('ssh', sshArguments(url), {
|
|
53
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
54
|
+
});
|
|
55
|
+
this.#child = child;
|
|
56
|
+
const closed = new Promise((resolve) => {
|
|
57
|
+
child.once('close', () => resolve());
|
|
58
|
+
});
|
|
59
|
+
this.exited = () => closed;
|
|
60
|
+
child.on('error', (error) => this.destroy(error));
|
|
61
|
+
child.stderr.setEncoding('utf8');
|
|
62
|
+
child.stderr.on('data', (chunk) => {
|
|
63
|
+
this.#stderr = (this.#stderr + chunk).slice(-STDERR_LIMIT);
|
|
64
|
+
});
|
|
65
|
+
child.stdout.on('data', (chunk) => {
|
|
66
|
+
if (!this.push(chunk))
|
|
67
|
+
child.stdout.pause();
|
|
68
|
+
});
|
|
69
|
+
child.stdout.once('end', () => {
|
|
70
|
+
void closed.then(() => {
|
|
71
|
+
const error = this.#exitError();
|
|
72
|
+
if (error)
|
|
73
|
+
this.destroy(error);
|
|
74
|
+
else
|
|
75
|
+
this.push(null);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
// A write to the standard input of an `ssh` that exited fails with EPIPE.
|
|
79
|
+
// The write callback reports it, after the exit of `ssh` gives the reason.
|
|
80
|
+
child.stdin.on('error', () => undefined);
|
|
81
|
+
}
|
|
82
|
+
/** The exit of `ssh` as an error, or undefined while it runs or when it exited with 0. */
|
|
83
|
+
#exitError() {
|
|
84
|
+
const { exitCode, signalCode } = this.#child;
|
|
85
|
+
if (exitCode === 0 || (exitCode === null && signalCode === null)) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
return new SshExitError(exitCode, signalCode, this.#stderr);
|
|
89
|
+
}
|
|
90
|
+
/** Gives the exit of `ssh` in place of an error of its pipes, when `ssh` exited. */
|
|
91
|
+
#fail(error, callback) {
|
|
92
|
+
void this.exited().then(() => callback(this.#exitError() ?? error));
|
|
93
|
+
}
|
|
94
|
+
_read() {
|
|
95
|
+
this.#child.stdout.resume();
|
|
96
|
+
}
|
|
97
|
+
_write(chunk, _encoding, callback) {
|
|
98
|
+
this.#child.stdin.write(chunk, (error) => {
|
|
99
|
+
if (error)
|
|
100
|
+
this.#fail(error, callback);
|
|
101
|
+
else
|
|
102
|
+
callback();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
_final(callback) {
|
|
106
|
+
this.#child.stdin.end((error) => {
|
|
107
|
+
if (error)
|
|
108
|
+
this.#fail(error, callback);
|
|
109
|
+
else
|
|
110
|
+
callback();
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
_destroy(error, callback) {
|
|
114
|
+
const { exitCode, signalCode } = this.#child;
|
|
115
|
+
if (exitCode === null && signalCode === null) {
|
|
116
|
+
// The disposal waits for the exit, so the exit must keep the process running.
|
|
117
|
+
this.#child.ref();
|
|
118
|
+
this.#child.kill();
|
|
119
|
+
}
|
|
120
|
+
this.#child.stdin.destroy();
|
|
121
|
+
this.#child.stdout.destroy();
|
|
122
|
+
this.#child.stderr.destroy();
|
|
123
|
+
callback(error);
|
|
124
|
+
}
|
|
125
|
+
/** An idle connection does not keep the process running. */
|
|
126
|
+
unref() {
|
|
127
|
+
this.#child.unref();
|
|
128
|
+
for (const pipe of this.#pipes())
|
|
129
|
+
pipe.unref();
|
|
130
|
+
}
|
|
131
|
+
/** A connection in use keeps the process running. */
|
|
132
|
+
ref() {
|
|
133
|
+
this.#child.ref();
|
|
134
|
+
for (const pipe of this.#pipes())
|
|
135
|
+
pipe.ref();
|
|
136
|
+
}
|
|
137
|
+
#pipes() {
|
|
138
|
+
return [this.#child.stdin, this.#child.stdout, this.#child.stderr].filter((pipe) => pipe instanceof Socket);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Keeps the idle connections to an SSH engine for the next request, and
|
|
143
|
+
* starts a new `ssh` for each request that finds no idle connection.
|
|
144
|
+
*/
|
|
145
|
+
class SshAgent extends Agent {
|
|
146
|
+
#url;
|
|
147
|
+
#connections = new Set();
|
|
148
|
+
constructor(url) {
|
|
149
|
+
super({ keepAlive: true });
|
|
150
|
+
this.#url = url;
|
|
151
|
+
}
|
|
152
|
+
createConnection() {
|
|
153
|
+
const connection = new SshConnection(this.#url);
|
|
154
|
+
this.#connections.add(connection);
|
|
155
|
+
void connection.exited().then(() => this.#connections.delete(connection));
|
|
156
|
+
return connection;
|
|
157
|
+
}
|
|
158
|
+
keepSocketAlive(socket) {
|
|
159
|
+
if (socket instanceof SshConnection)
|
|
160
|
+
socket.unref();
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
reuseSocket(socket) {
|
|
164
|
+
if (socket instanceof SshConnection)
|
|
165
|
+
socket.ref();
|
|
166
|
+
}
|
|
167
|
+
/** Ends each `ssh` process and resolves when each one exited. */
|
|
168
|
+
async close() {
|
|
169
|
+
const connections = [...this.#connections];
|
|
170
|
+
this.destroy();
|
|
171
|
+
for (const connection of connections)
|
|
172
|
+
connection.destroy();
|
|
173
|
+
await Promise.all(connections.map((connection) => connection.exited()));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** The connections to an engine at an ssh:// host. Each connection is one `ssh` process. */
|
|
177
|
+
export class SshTransport {
|
|
178
|
+
#agent;
|
|
179
|
+
constructor(url) {
|
|
180
|
+
this.#agent = new SshAgent(url);
|
|
181
|
+
}
|
|
182
|
+
request(options) {
|
|
183
|
+
return request({ ...options, agent: this.#agent });
|
|
184
|
+
}
|
|
185
|
+
async close() {
|
|
186
|
+
await this.#agent.close();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=ssh-connection.js.map
|
|
@@ -0,0 +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;AAIrC,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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,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,OAAuB;QAC7B,OAAO,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ClientRequest, type RequestOptions } from 'node:http';
|
|
2
|
+
/** The connections of a client to its engine. */
|
|
3
|
+
export interface Transport {
|
|
4
|
+
request(options: RequestOptions): ClientRequest;
|
|
5
|
+
/** Closes each connection, idle or in use, and resolves when each one is closed. */
|
|
6
|
+
close(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The connections to one engine through a Unix socket or a Windows named pipe.
|
|
10
|
+
* It keeps idle connections for the next request, and an idle connection does
|
|
11
|
+
* not keep the process running: the agent unrefs each free socket.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SocketTransport implements Transport {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(socketPath: string);
|
|
16
|
+
request(options: RequestOptions): ClientRequest;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,iDAAiD;AACjD,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAAC;IAChD,oFAAoF;IACpF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,SAAS;;gBAInC,UAAU,EAAE,MAAM;IAI9B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa;IAQzC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Agent, request, } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* The connections to one engine through a Unix socket or a Windows named pipe.
|
|
4
|
+
* It keeps idle connections for the next request, and an idle connection does
|
|
5
|
+
* not keep the process running: the agent unrefs each free socket.
|
|
6
|
+
*/
|
|
7
|
+
export class SocketTransport {
|
|
8
|
+
#socketPath;
|
|
9
|
+
#agent = new Agent({ keepAlive: true });
|
|
10
|
+
constructor(socketPath) {
|
|
11
|
+
this.#socketPath = socketPath;
|
|
12
|
+
}
|
|
13
|
+
request(options) {
|
|
14
|
+
return request({
|
|
15
|
+
...options,
|
|
16
|
+
agent: this.#agent,
|
|
17
|
+
socketPath: this.#socketPath,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async close() {
|
|
21
|
+
this.#agent.destroy();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAGL,OAAO,GACR,MAAM,WAAW,CAAC;AASnB;;;;GAIG;AACH,MAAM,OAAO,eAAe;IACjB,WAAW,CAAS;IACpB,MAAM,GAAG,IAAI,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjD,YAAY,UAAkB;QAC5B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,OAAuB;QAC7B,OAAO,OAAO,CAAC;YACb,GAAG,OAAO;YACV,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,UAAU,EAAE,IAAI,CAAC,WAAW;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/docker",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.33",
|
|
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 dependencies.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/JanuaryLabs/zukhruf",
|
|
9
|
+
"directory": "packages/docker"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/JanuaryLabs/zukhruf/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/JanuaryLabs/zukhruf/tree/main/packages/docker#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"docker",
|
|
17
|
+
"docker-engine",
|
|
18
|
+
"engine-api",
|
|
19
|
+
"container",
|
|
20
|
+
"docker-context",
|
|
21
|
+
"unix-socket"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
|
+
".": {
|
|
27
|
+
"@zukhruf/source": "./src/index.ts",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"!dist/spec/**",
|
|
36
|
+
"!**/*.tsbuildinfo",
|
|
37
|
+
"!**/*.test.*"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|