@zukhruf/docker 0.3.33 → 0.3.35
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 +26 -12
- package/dist/container-process.d.ts +35 -0
- package/dist/container-process.d.ts.map +1 -0
- package/dist/container-process.js +91 -0
- package/dist/container-process.js.map +1 -0
- package/dist/containers.d.ts +160 -0
- package/dist/containers.d.ts.map +1 -0
- package/dist/containers.js +700 -0
- package/dist/containers.js.map +1 -0
- package/dist/docker.d.ts +25 -2
- package/dist/docker.d.ts.map +1 -1
- package/dist/docker.js +43 -7
- package/dist/docker.js.map +1 -1
- package/dist/engine-api.d.ts +369 -0
- package/dist/engine-api.d.ts.map +1 -1
- package/dist/engine-client.d.ts +52 -4
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +167 -31
- package/dist/engine-client.js.map +1 -1
- package/dist/errors.d.ts +95 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +156 -6
- package/dist/errors.js.map +1 -1
- package/dist/images.d.ts +40 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +173 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/multiplexed-stream.d.ts +11 -0
- package/dist/multiplexed-stream.d.ts.map +1 -0
- package/dist/multiplexed-stream.js +81 -0
- package/dist/multiplexed-stream.js.map +1 -0
- package/dist/ndjson.d.ts +7 -0
- package/dist/ndjson.d.ts.map +1 -0
- package/dist/ndjson.js +21 -0
- package/dist/ndjson.js.map +1 -0
- package/dist/networks.d.ts +46 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +170 -0
- package/dist/networks.js.map +1 -0
- package/dist/output.d.ts +18 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +21 -0
- package/dist/output.js.map +1 -0
- package/dist/progress.d.ts +9 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +20 -0
- package/dist/progress.js.map +1 -0
- package/dist/ssh-connection.d.ts +3 -0
- package/dist/ssh-connection.d.ts.map +1 -1
- package/dist/ssh-connection.js +46 -10
- package/dist/ssh-connection.js.map +1 -1
- package/dist/tar-reader.d.ts +22 -0
- package/dist/tar-reader.d.ts.map +1 -0
- package/dist/tar-reader.js +163 -0
- package/dist/tar-reader.js.map +1 -0
- package/dist/tar-writer.d.ts +16 -0
- package/dist/tar-writer.d.ts.map +1 -0
- package/dist/tar-writer.js +114 -0
- package/dist/tar-writer.js.map +1 -0
- package/dist/transport.d.ts +11 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +34 -2
- package/dist/transport.js.map +1 -1
- package/dist/volumes.d.ts +41 -0
- package/dist/volumes.d.ts.map +1 -0
- package/dist/volumes.js +119 -0
- package/dist/volumes.js.map +1 -0
- package/package.json +5 -2
package/dist/engine-client.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import type { IncomingHttpHeaders } from 'node:http';
|
|
1
|
+
import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
|
|
2
|
+
import { type Duplex, Readable } from 'node:stream';
|
|
3
|
+
import { DockerEngineError } from './errors.ts';
|
|
2
4
|
import type { Filters } from './options.ts';
|
|
3
5
|
import type { Transport } from './transport.ts';
|
|
4
|
-
/** The query of a request. `filters` goes to the engine as JSON. */
|
|
5
|
-
export type Query = Record<string, string | number | boolean | Filters | undefined>;
|
|
6
|
+
/** The query of a request. An array repeats the parameter; `filters` goes to the engine as JSON. */
|
|
7
|
+
export type Query = Record<string, string | number | boolean | string[] | Filters | undefined>;
|
|
6
8
|
export interface EngineRequestOptions {
|
|
7
9
|
query?: Query | undefined;
|
|
10
|
+
/** Goes to the engine as JSON. */
|
|
11
|
+
body?: unknown;
|
|
12
|
+
/** Goes to the engine as it is, with its media type, in place of a JSON body. */
|
|
13
|
+
content?: {
|
|
14
|
+
type: string;
|
|
15
|
+
data: Uint8Array | AsyncIterable<Uint8Array>;
|
|
16
|
+
} | undefined;
|
|
17
|
+
headers?: Record<string, string> | undefined;
|
|
8
18
|
signal?: AbortSignal | undefined;
|
|
9
19
|
}
|
|
10
20
|
export interface EngineResponse {
|
|
@@ -12,15 +22,53 @@ export interface EngineResponse {
|
|
|
12
22
|
headers: IncomingHttpHeaders;
|
|
13
23
|
body: Buffer;
|
|
14
24
|
}
|
|
25
|
+
/** A connection that the engine upgraded to a two-way stream of bytes. */
|
|
26
|
+
export interface HijackedConnection {
|
|
27
|
+
/** The output of the engine, then the input to the engine. */
|
|
28
|
+
readonly socket: Duplex;
|
|
29
|
+
/** The bytes of the output that came with the answer, before the first read of the socket. */
|
|
30
|
+
readonly head: Buffer;
|
|
31
|
+
/** The Content-Type of the answer: application/vnd.docker.multiplexed-stream or application/vnd.docker.raw-stream. */
|
|
32
|
+
readonly contentType: string;
|
|
33
|
+
/** Ends the input through the end of input of the transport. The output stays open. */
|
|
34
|
+
endInput(): void;
|
|
35
|
+
}
|
|
36
|
+
/** True for a 2xx status. */
|
|
37
|
+
export declare function isSuccess(response: EngineResponse): boolean;
|
|
38
|
+
/** The JSON body of an answer. */
|
|
39
|
+
export declare function parseBody<T>(response: EngineResponse): T;
|
|
15
40
|
/** Sends requests of the Engine API to one engine. */
|
|
16
41
|
export declare class EngineClient {
|
|
17
42
|
#private;
|
|
18
|
-
constructor(host: string, transport: Transport, apiVersion?: string);
|
|
43
|
+
constructor(host: string, transport: Transport, apiVersion?: string, streams?: Set<Readable>, disposal?: AbortController);
|
|
19
44
|
/** The same engine and connections, with the API version in the path of each request. */
|
|
20
45
|
versioned(apiVersion: string): EngineClient;
|
|
46
|
+
/**
|
|
47
|
+
* Closes each connection, and resolves when each one is closed. A request
|
|
48
|
+
* in flight, a request that starts after close() started, and an iteration
|
|
49
|
+
* of a stream that is open reject with a DockerError that says that the
|
|
50
|
+
* client was disposed.
|
|
51
|
+
*/
|
|
52
|
+
close(): Promise<void>;
|
|
21
53
|
/** Sends a request. A status that is not 2xx rejects with DockerEngineError. */
|
|
22
54
|
request(method: string, path: string, options?: EngineRequestOptions): Promise<EngineResponse>;
|
|
23
55
|
/** Sends a request and gives its JSON body. */
|
|
24
56
|
json<T>(method: string, path: string, options?: EngineRequestOptions): Promise<T>;
|
|
57
|
+
/** Sends a request and gives the answer with each status. */
|
|
58
|
+
exchange(method: string, path: string, options?: EngineRequestOptions): Promise<EngineResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Sends a request and gives the body of a 2xx answer as it comes. An abort
|
|
61
|
+
* of the signal rejects the read of the body with its reason. Each other
|
|
62
|
+
* status rejects with DockerEngineError.
|
|
63
|
+
*/
|
|
64
|
+
stream(method: string, path: string, options?: EngineRequestOptions): Promise<IncomingMessage>;
|
|
65
|
+
/**
|
|
66
|
+
* Sends a request that the engine upgrades to a hijacked connection, for an
|
|
67
|
+
* attach and for the start of an exec. An answer without an upgrade
|
|
68
|
+
* rejects with DockerEngineError.
|
|
69
|
+
*/
|
|
70
|
+
hijack(method: string, path: string, options?: EngineRequestOptions): Promise<HijackedConnection>;
|
|
71
|
+
/** The DockerEngineError of an answer that is not 2xx. */
|
|
72
|
+
error(response: EngineResponse, method: string, path: string): DockerEngineError;
|
|
25
73
|
}
|
|
26
74
|
//# sourceMappingURL=engine-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-client.d.ts","sourceRoot":"","sources":["../src/engine-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine-client.d.ts","sourceRoot":"","sources":["../src/engine-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,KAAK,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAEL,iBAAiB,EAElB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,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YAAY;;gBAcrB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,gBAAsB,EAC7B,QAAQ,kBAAwB;IAWlC,yFAAyF;IACzF,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY;IAU3C;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B,gFAAgF;IAC1E,OAAO,CACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,cAAc,CAAC;IAM1B,+CAA+C;IACzC,IAAI,CAAC,CAAC,EACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,CAAC,CAAC;IAIb,6DAA6D;IACvD,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,cAAc,CAAC;IAS1B;;;;OAIG;IACG,MAAM,CACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,eAAe,CAAC;IAW3B;;;;OAIG;IACG,MAAM,CACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC;IA6B9B,0DAA0D;IAC1D,KAAK,CACH,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,iBAAiB;CA0FrB"}
|
package/dist/engine-client.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setMaxListeners } from 'node:events';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
import { pipeline } from 'node:stream/promises';
|
|
4
|
+
import { ConnectionFailedError, DockerEngineError, DockerError, } from "./errors.js";
|
|
2
5
|
import { SshExitError } from "./ssh-connection.js";
|
|
3
6
|
/** The socket errors that mean the engine did not accept the connection. ENOENT is also an absent `ssh`. */
|
|
4
7
|
const CONNECTION_FAILURES = new Set([
|
|
@@ -19,6 +22,11 @@ function search(query) {
|
|
|
19
22
|
for (const [key, value] of Object.entries(query ?? {})) {
|
|
20
23
|
if (value === undefined)
|
|
21
24
|
continue;
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
for (const each of value)
|
|
27
|
+
parameters.append(key, each);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
22
30
|
parameters.set(key, typeof value === 'object' ? JSON.stringify(value) : String(value));
|
|
23
31
|
}
|
|
24
32
|
const text = parameters.toString();
|
|
@@ -38,79 +46,207 @@ function engineMessage(response) {
|
|
|
38
46
|
}
|
|
39
47
|
return text.trim();
|
|
40
48
|
}
|
|
49
|
+
/** True for a 2xx status. */
|
|
50
|
+
export function isSuccess(response) {
|
|
51
|
+
return response.status >= 200 && response.status <= 299;
|
|
52
|
+
}
|
|
53
|
+
/** The JSON body of an answer. */
|
|
54
|
+
export function parseBody(response) {
|
|
55
|
+
const body = JSON.parse(response.body.toString('utf8'));
|
|
56
|
+
return body;
|
|
57
|
+
}
|
|
58
|
+
async function readAll(response) {
|
|
59
|
+
const chunks = [];
|
|
60
|
+
for await (const chunk of response)
|
|
61
|
+
chunks.push(Buffer.from(chunk));
|
|
62
|
+
return Buffer.concat(chunks);
|
|
63
|
+
}
|
|
41
64
|
/** Sends requests of the Engine API to one engine. */
|
|
42
65
|
export class EngineClient {
|
|
43
66
|
#host;
|
|
44
67
|
#transport;
|
|
45
68
|
#apiVersion;
|
|
46
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The bodies of streamed answers and the hijacked connections that are
|
|
71
|
+
* open. After an upgrade, the agent of the transport no longer has the
|
|
72
|
+
* socket, so only this set lets close() reach it.
|
|
73
|
+
*/
|
|
74
|
+
#streams;
|
|
75
|
+
/** Aborts when close() starts. Its reason is the DockerError of the disposal. */
|
|
76
|
+
#disposal;
|
|
77
|
+
constructor(host, transport, apiVersion, streams = new Set(), disposal = new AbortController()) {
|
|
47
78
|
this.#host = host;
|
|
48
79
|
this.#transport = transport;
|
|
49
80
|
this.#apiVersion = apiVersion;
|
|
81
|
+
this.#streams = streams;
|
|
82
|
+
this.#disposal = disposal;
|
|
83
|
+
// Each request in flight listens to the disposal, so many concurrent requests are not a leak.
|
|
84
|
+
setMaxListeners(0, disposal.signal);
|
|
50
85
|
}
|
|
51
86
|
/** The same engine and connections, with the API version in the path of each request. */
|
|
52
87
|
versioned(apiVersion) {
|
|
53
|
-
return new EngineClient(this.#host, this.#transport, apiVersion);
|
|
88
|
+
return new EngineClient(this.#host, this.#transport, apiVersion, this.#streams, this.#disposal);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Closes each connection, and resolves when each one is closed. A request
|
|
92
|
+
* in flight, a request that starts after close() started, and an iteration
|
|
93
|
+
* of a stream that is open reject with a DockerError that says that the
|
|
94
|
+
* client was disposed.
|
|
95
|
+
*/
|
|
96
|
+
async close() {
|
|
97
|
+
const error = new DockerError('The client was disposed, so it closed this connection to the engine.');
|
|
98
|
+
this.#disposal.abort(error);
|
|
99
|
+
for (const stream of this.#streams)
|
|
100
|
+
stream.destroy(error);
|
|
101
|
+
this.#streams.clear();
|
|
102
|
+
await this.#transport.close();
|
|
103
|
+
}
|
|
104
|
+
#hold(stream) {
|
|
105
|
+
this.#streams.add(stream);
|
|
106
|
+
stream.once('close', () => this.#streams.delete(stream));
|
|
54
107
|
}
|
|
55
108
|
/** Sends a request. A status that is not 2xx rejects with DockerEngineError. */
|
|
56
109
|
async request(method, path, options = {}) {
|
|
57
|
-
const response = await this
|
|
58
|
-
if (response
|
|
59
|
-
throw
|
|
60
|
-
status: response.status,
|
|
61
|
-
method,
|
|
62
|
-
path,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
110
|
+
const response = await this.exchange(method, path, options);
|
|
111
|
+
if (!isSuccess(response))
|
|
112
|
+
throw this.error(response, method, path);
|
|
65
113
|
return response;
|
|
66
114
|
}
|
|
67
115
|
/** Sends a request and gives its JSON body. */
|
|
68
116
|
async json(method, path, options = {}) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
117
|
+
return parseBody(await this.request(method, path, options));
|
|
118
|
+
}
|
|
119
|
+
/** Sends a request and gives the answer with each status. */
|
|
120
|
+
async exchange(method, path, options = {}) {
|
|
121
|
+
const { response } = await this.#open(method, path, options);
|
|
122
|
+
return {
|
|
123
|
+
status: response.statusCode ?? 0,
|
|
124
|
+
headers: response.headers,
|
|
125
|
+
body: await readAll(response),
|
|
126
|
+
};
|
|
72
127
|
}
|
|
73
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Sends a request and gives the body of a 2xx answer as it comes. An abort
|
|
130
|
+
* of the signal rejects the read of the body with its reason. Each other
|
|
131
|
+
* status rejects with DockerEngineError.
|
|
132
|
+
*/
|
|
133
|
+
async stream(method, path, options = {}) {
|
|
134
|
+
const { response } = await this.#open(method, path, options);
|
|
135
|
+
const status = response.statusCode ?? 0;
|
|
136
|
+
if (status >= 200 && status <= 299) {
|
|
137
|
+
this.#hold(response);
|
|
138
|
+
return response;
|
|
139
|
+
}
|
|
140
|
+
const body = await readAll(response);
|
|
141
|
+
throw this.error({ status, headers: response.headers, body }, method, path);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Sends a request that the engine upgrades to a hijacked connection, for an
|
|
145
|
+
* attach and for the start of an exec. An answer without an upgrade
|
|
146
|
+
* rejects with DockerEngineError.
|
|
147
|
+
*/
|
|
148
|
+
async hijack(method, path, options = {}) {
|
|
149
|
+
const { response, upgrade } = await this.#open(method, path, {
|
|
150
|
+
...options,
|
|
151
|
+
headers: { ...options.headers, Connection: 'Upgrade', Upgrade: 'tcp' },
|
|
152
|
+
}, true);
|
|
153
|
+
if (upgrade === undefined) {
|
|
154
|
+
const body = await readAll(response);
|
|
155
|
+
throw this.error({ status: response.statusCode ?? 0, headers: response.headers, body }, method, path);
|
|
156
|
+
}
|
|
157
|
+
const { socket, head } = upgrade;
|
|
158
|
+
this.#hold(socket);
|
|
159
|
+
const transport = this.#transport;
|
|
160
|
+
return {
|
|
161
|
+
socket,
|
|
162
|
+
head,
|
|
163
|
+
contentType: response.headers['content-type'] ?? '',
|
|
164
|
+
endInput: () => transport.endInput(socket),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** The DockerEngineError of an answer that is not 2xx. */
|
|
168
|
+
error(response, method, path) {
|
|
169
|
+
return new DockerEngineError(engineMessage(response), {
|
|
170
|
+
status: response.status,
|
|
171
|
+
request: { method, path },
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async #open(method, path, { query, body, content, headers, signal }, upgrades = false) {
|
|
74
175
|
signal?.throwIfAborted();
|
|
176
|
+
const disposal = this.#disposal.signal;
|
|
177
|
+
disposal.throwIfAborted();
|
|
75
178
|
const prefix = this.#apiVersion === undefined ? '' : `/v${this.#apiVersion}`;
|
|
179
|
+
const payload = body === undefined
|
|
180
|
+
? content?.data
|
|
181
|
+
: new TextEncoder().encode(JSON.stringify(body));
|
|
182
|
+
const contentType = body === undefined ? content?.type : 'application/json';
|
|
76
183
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
77
184
|
const request = this.#transport.request({
|
|
78
185
|
method,
|
|
79
186
|
path: `${prefix}${path}${search(query)}`,
|
|
187
|
+
headers: {
|
|
188
|
+
...headers,
|
|
189
|
+
...(contentType === undefined ? {} : { 'Content-Type': contentType }),
|
|
190
|
+
...(payload instanceof Uint8Array
|
|
191
|
+
? { 'Content-Length': payload.byteLength }
|
|
192
|
+
: {}),
|
|
193
|
+
},
|
|
80
194
|
});
|
|
195
|
+
const responses = [];
|
|
81
196
|
const abort = () => {
|
|
82
197
|
reject(signal?.reason);
|
|
83
198
|
request.destroy();
|
|
199
|
+
for (const response of responses)
|
|
200
|
+
response.destroy(signal?.reason);
|
|
201
|
+
};
|
|
202
|
+
// The disposal ends the exchange as an abort of the signal does, with the DockerError of the disposal.
|
|
203
|
+
const dispose = () => {
|
|
204
|
+
reject(disposal.reason);
|
|
205
|
+
request.destroy();
|
|
206
|
+
for (const response of responses)
|
|
207
|
+
response.destroy(disposal.reason);
|
|
84
208
|
};
|
|
85
209
|
signal?.addEventListener('abort', abort, { once: true });
|
|
86
|
-
|
|
210
|
+
disposal.addEventListener('abort', dispose, { once: true });
|
|
211
|
+
const release = () => {
|
|
212
|
+
signal?.removeEventListener('abort', abort);
|
|
213
|
+
disposal.removeEventListener('abort', dispose);
|
|
214
|
+
};
|
|
87
215
|
request.on('error', (error) => {
|
|
88
216
|
// An error after the answer started is not a connection failure.
|
|
89
|
-
reject(
|
|
217
|
+
reject(responses.length === 0 &&
|
|
90
218
|
(error instanceof SshExitError ||
|
|
91
219
|
CONNECTION_FAILURES.has(errorCode(error) ?? ''))
|
|
92
220
|
? new ConnectionFailedError(this.#host, { cause: error })
|
|
93
221
|
: error);
|
|
94
222
|
});
|
|
95
223
|
request.on('response', (response) => {
|
|
96
|
-
|
|
97
|
-
response.
|
|
98
|
-
|
|
99
|
-
response.on('data', (chunk) => chunks.push(chunk));
|
|
100
|
-
response.on('end', () => {
|
|
101
|
-
resolve({
|
|
102
|
-
status: response.statusCode ?? 0,
|
|
103
|
-
headers: response.headers,
|
|
104
|
-
body: Buffer.concat(chunks),
|
|
105
|
-
});
|
|
106
|
-
});
|
|
224
|
+
responses.push(response);
|
|
225
|
+
response.once('close', release);
|
|
226
|
+
resolve({ response });
|
|
107
227
|
});
|
|
108
|
-
|
|
228
|
+
if (upgrades) {
|
|
229
|
+
// The caller owns the socket after the upgrade, and its signal too.
|
|
230
|
+
request.on('upgrade', (response, socket, head) => {
|
|
231
|
+
release();
|
|
232
|
+
resolve({ response, upgrade: { socket, head } });
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (payload === undefined || payload instanceof Uint8Array) {
|
|
236
|
+
request.end(payload);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
// A body that comes as a stream goes with chunked encoding, at the pace of the connection.
|
|
240
|
+
pipeline(Readable.from(payload), request).catch((error) => {
|
|
241
|
+
request.destroy(error instanceof Error ? error : undefined);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
109
244
|
try {
|
|
110
245
|
return await promise;
|
|
111
246
|
}
|
|
112
|
-
|
|
113
|
-
|
|
247
|
+
catch (error) {
|
|
248
|
+
release();
|
|
249
|
+
throw error;
|
|
114
250
|
}
|
|
115
251
|
}
|
|
116
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-client.js","sourceRoot":"","sources":["../src/engine-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine-client.js","sourceRoot":"","sources":["../src/engine-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA2CnD,4GAA4G;AAC5G,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,QAAQ;IACR,cAAc;IACd,OAAO;IACP,YAAY;CACb,CAAC,CAAC;AAEH,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK;QAC3B,MAAM,IAAI,KAAK;QACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,CAAC,CAAC,KAAK,CAAC,IAAI;QACZ,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,MAAM,CAAC,KAAwB;IACtC,MAAM,UAAU,GAAG,IAA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,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE,CAAC;YACb,oEAAoE;YACpE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;gBAC/C,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,YAAY,UAAU,EAAE,CAAC;YAC3D,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,2FAA2F;YAC3F,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBACjE,OAAO,CAAC,OAAO,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAC;YACV,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -26,18 +26,108 @@ export declare class UnsupportedEngineError extends DockerError {
|
|
|
26
26
|
readonly minimumVersion: string;
|
|
27
27
|
constructor(host: string, engineVersion: string, minimumVersion: string);
|
|
28
28
|
}
|
|
29
|
+
/** The method and the path of a request of the Engine API, without the API version and the query. */
|
|
29
30
|
export interface EngineRequest {
|
|
31
|
+
readonly method: string;
|
|
32
|
+
readonly path: string;
|
|
33
|
+
}
|
|
34
|
+
/** The answer that is an error: its status and the request that got it. A DockerEngineError is one too. */
|
|
35
|
+
export interface EngineAnswer {
|
|
30
36
|
/** The HTTP status; undefined for an error in the progress of a pull, a push or a load. */
|
|
31
|
-
status: number | undefined;
|
|
32
|
-
|
|
33
|
-
path: string;
|
|
37
|
+
readonly status: number | undefined;
|
|
38
|
+
readonly request: EngineRequest;
|
|
34
39
|
}
|
|
35
40
|
/** The base of every answer of the engine that is an error. Its message is the message of the engine. */
|
|
36
41
|
export declare class DockerEngineError extends DockerError {
|
|
37
42
|
/** The HTTP status; undefined for an error in the progress of a pull, a push or a load. */
|
|
38
43
|
readonly status: number | undefined;
|
|
39
|
-
|
|
44
|
+
/** The request that got the error. */
|
|
45
|
+
readonly request: EngineRequest;
|
|
46
|
+
constructor(message: string, answer: EngineAnswer, options?: ErrorOptions);
|
|
47
|
+
}
|
|
48
|
+
/** A request about a container got 404. */
|
|
49
|
+
export declare class ContainerNotFoundError extends DockerEngineError {
|
|
50
|
+
readonly container: string;
|
|
51
|
+
constructor(message: string, answer: EngineAnswer, container: string, options?: ErrorOptions);
|
|
52
|
+
}
|
|
53
|
+
/** An exec or a kill got 409, or an attach found the container exited or paused. */
|
|
54
|
+
export declare class ContainerNotRunningError extends DockerEngineError {
|
|
55
|
+
readonly container: string;
|
|
56
|
+
/** From an inspect after the 409: 'created', 'exited', 'paused', 'restarting', 'removing' or 'dead'. */
|
|
57
|
+
readonly state: string;
|
|
58
|
+
constructor(message: string, answer: EngineAnswer, container: string, state: string, options?: ErrorOptions);
|
|
59
|
+
}
|
|
60
|
+
/** A create of a container, network or volume found the name taken. */
|
|
61
|
+
export declare class NameConflictError extends DockerEngineError {
|
|
62
|
+
readonly kind: 'container' | 'network' | 'volume';
|
|
63
|
+
/** The name that another resource has. Not `name`: that is the name of the error class. */
|
|
64
|
+
readonly takenName: string;
|
|
65
|
+
constructor(message: string, answer: EngineAnswer, kind: 'container' | 'network' | 'volume', takenName: string, options?: ErrorOptions);
|
|
66
|
+
}
|
|
67
|
+
/** A removal without `force` got 409, and an inspect showed that the container runs. */
|
|
68
|
+
export declare class ContainerRunningError extends DockerEngineError {
|
|
69
|
+
readonly container: string;
|
|
70
|
+
constructor(message: string, answer: EngineAnswer, container: string, options?: ErrorOptions);
|
|
71
|
+
}
|
|
72
|
+
/** A create got 404 and the image is not on the engine, a pull got 404, or a push found no image of the reference on the engine. */
|
|
73
|
+
export declare class ImageNotFoundError extends DockerEngineError {
|
|
74
|
+
readonly image: string;
|
|
75
|
+
constructor(message: string, answer: EngineAnswer, image: string, options?: ErrorOptions);
|
|
76
|
+
}
|
|
77
|
+
/** A start got 404 while the container exists, and a lookup of its networks found one missing; or a request about a network got 404. */
|
|
78
|
+
export declare class NetworkNotFoundError extends DockerEngineError {
|
|
79
|
+
readonly network: string;
|
|
80
|
+
constructor(message: string, answer: EngineAnswer, network: string, options?: ErrorOptions);
|
|
81
|
+
}
|
|
82
|
+
/** A request about a volume got 404. */
|
|
83
|
+
export declare class VolumeNotFoundError extends DockerEngineError {
|
|
84
|
+
readonly volume: string;
|
|
85
|
+
constructor(message: string, answer: EngineAnswer, volume: string, options?: ErrorOptions);
|
|
86
|
+
}
|
|
87
|
+
/** A volume removal got 409: a container uses the volume. */
|
|
88
|
+
export declare class VolumeInUseError extends DockerEngineError {
|
|
89
|
+
readonly volume: string;
|
|
90
|
+
constructor(message: string, answer: EngineAnswer, volume: string, options?: ErrorOptions);
|
|
91
|
+
}
|
|
92
|
+
/** A network removal got 403 while containers are connected. */
|
|
93
|
+
export declare class NetworkInUseError extends DockerEngineError {
|
|
94
|
+
readonly network: string;
|
|
95
|
+
/** The IDs of the connected containers, from an inspect after the 403. */
|
|
96
|
+
readonly containers: string[];
|
|
97
|
+
constructor(message: string, answer: EngineAnswer, network: string, containers: string[], options?: ErrorOptions);
|
|
98
|
+
}
|
|
99
|
+
/** An image removal got 409. */
|
|
100
|
+
export declare class ImageInUseError extends DockerEngineError {
|
|
101
|
+
readonly image: string;
|
|
102
|
+
constructor(message: string, answer: EngineAnswer, image: string, options?: ErrorOptions);
|
|
103
|
+
}
|
|
104
|
+
/** A create or a start refused a bind mount whose source does not exist on the host of the engine. */
|
|
105
|
+
export declare class BindSourceNotFoundError extends DockerEngineError {
|
|
106
|
+
/** The path on the host of the engine. */
|
|
107
|
+
readonly source: string;
|
|
108
|
+
constructor(message: string, answer: EngineAnswer, source: string, options?: ErrorOptions);
|
|
109
|
+
}
|
|
110
|
+
/** A file request got 404, and the container exists. */
|
|
111
|
+
export declare class PathNotFoundError extends DockerEngineError {
|
|
112
|
+
readonly container: string;
|
|
113
|
+
/** The path in the container. */
|
|
114
|
+
readonly path: string;
|
|
115
|
+
constructor(message: string, answer: EngineAnswer, container: string, path: string, options?: ErrorOptions);
|
|
116
|
+
}
|
|
117
|
+
/** readFile() found a directory, a link or another kind of entry. */
|
|
118
|
+
export declare class NotAFileError extends DockerEngineError {
|
|
119
|
+
readonly container: string;
|
|
120
|
+
/** The path in the container. */
|
|
121
|
+
readonly path: string;
|
|
122
|
+
/** The kind of the entry: 'directory', 'symlink', 'link' or 'other'. */
|
|
123
|
+
readonly kind: 'directory' | 'symlink' | 'link' | 'other';
|
|
124
|
+
constructor(message: string, answer: EngineAnswer, container: string, path: string, kind: 'directory' | 'symlink' | 'link' | 'other', options?: ErrorOptions);
|
|
125
|
+
}
|
|
126
|
+
/** The engine refused an extraction, and an inspect showed that the directory is on a read-only root filesystem or in a read-only mount. */
|
|
127
|
+
export declare class ReadOnlyPathError extends DockerEngineError {
|
|
128
|
+
readonly container: string;
|
|
129
|
+
/** The path in the container. */
|
|
40
130
|
readonly path: string;
|
|
41
|
-
constructor(message: string,
|
|
131
|
+
constructor(message: string, answer: EngineAnswer, container: string, path: string, options?: ErrorOptions);
|
|
42
132
|
}
|
|
43
133
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRo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