testcontainers 8.13.1-beta.3 → 8.13.1-beta.4
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/dist/docker/functions/container/attach-container.d.ts +1 -1
- package/dist/docker/functions/container/attach-container.js +2 -2
- package/dist/docker/functions/container/container-logs.js +2 -1
- package/dist/docker/functions/demux-stream.d.ts +2 -1
- package/dist/docker/functions/demux-stream.js +1 -3
- package/dist/docker/functions/run-in-container.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Readable } from "stream";
|
|
2
2
|
import Dockerode from "dockerode";
|
|
3
|
-
export declare const attachContainer: (container: Dockerode.Container) => Promise<Readable>;
|
|
3
|
+
export declare const attachContainer: (dockerode: Dockerode, container: Dockerode.Container) => Promise<Readable>;
|
|
@@ -12,10 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.attachContainer = void 0;
|
|
13
13
|
const demux_stream_1 = require("../demux-stream");
|
|
14
14
|
const logger_1 = require("../../../logger");
|
|
15
|
-
const attachContainer = (container) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const attachContainer = (dockerode, container) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
17
|
const stream = (yield container.attach({ stream: true, stdout: true, stderr: true }));
|
|
18
|
-
return (0, demux_stream_1.demuxStream)(stream);
|
|
18
|
+
return (0, demux_stream_1.demuxStream)(dockerode, stream);
|
|
19
19
|
}
|
|
20
20
|
catch (err) {
|
|
21
21
|
logger_1.log.error(`Failed to attach to container ${container.id}: ${err}`);
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.containerLogs = void 0;
|
|
13
13
|
const logger_1 = require("../../../logger");
|
|
14
14
|
const demux_stream_1 = require("../demux-stream");
|
|
15
|
+
const docker_client_1 = require("../../docker-client");
|
|
15
16
|
const containerLogs = (container) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
17
|
try {
|
|
17
18
|
const options = {
|
|
@@ -21,7 +22,7 @@ const containerLogs = (container) => __awaiter(void 0, void 0, void 0, function*
|
|
|
21
22
|
};
|
|
22
23
|
const stream = (yield container.logs(options));
|
|
23
24
|
stream.socket.unref();
|
|
24
|
-
return (0, demux_stream_1.demuxStream)(stream);
|
|
25
|
+
return (0, demux_stream_1.demuxStream)((yield (0, docker_client_1.dockerClient)()).dockerode, stream);
|
|
25
26
|
}
|
|
26
27
|
catch (err) {
|
|
27
28
|
logger_1.log.error(`Failed to get container logs: ${err}`);
|
|
@@ -12,11 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.demuxStream = void 0;
|
|
13
13
|
const stream_1 = require("stream");
|
|
14
14
|
const logger_1 = require("../../logger");
|
|
15
|
-
const
|
|
16
|
-
const demuxStream = (stream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const demuxStream = (dockerode, stream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
16
|
try {
|
|
18
17
|
const demuxedStream = new stream_1.PassThrough({ autoDestroy: true, encoding: "utf-8" });
|
|
19
|
-
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
20
18
|
dockerode.modem.demuxStream(stream, demuxedStream, demuxedStream);
|
|
21
19
|
stream.on("end", () => demuxedStream.end());
|
|
22
20
|
demuxedStream.on("close", () => {
|
|
@@ -23,7 +23,7 @@ const runInContainer = (dockerode, image, command) => __awaiter(void 0, void 0,
|
|
|
23
23
|
logger_1.log.debug(`Creating container: ${image} with command: ${command.join(" ")}`);
|
|
24
24
|
const container = yield dockerode.createContainer({ Image: image, Cmd: command, HostConfig: { AutoRemove: true } });
|
|
25
25
|
logger_1.log.debug(`Attaching to container: ${container.id}`);
|
|
26
|
-
const stream = yield (0, attach_container_1.attachContainer)(container);
|
|
26
|
+
const stream = yield (0, attach_container_1.attachContainer)(dockerode, container);
|
|
27
27
|
const promise = new Promise((resolve) => {
|
|
28
28
|
const interval = setInterval(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
29
|
const inspect = yield (0, inspect_container_1.inspectContainer)(container);
|