Skip to content

Commit 215abd8

Browse files
Fixes for docker-compose
1 parent f701426 commit 215abd8

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

packages/testcontainers/src/container-runtime/clients/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async function initStrategy(strategy: ContainerRuntimeClientStrategy): Promise<C
123123
labels: dockerodeInfo.Labels ? dockerodeInfo.Labels : [],
124124
};
125125

126-
const composeInfo: ComposeInfo = composeClient.info;
126+
const composeInfo: ComposeInfo = composeClient.version;
127127

128128
const info: Info = { node: nodeInfo, containerRuntime: containerRuntimeInfo, compose: composeInfo };
129129

packages/testcontainers/src/container-runtime/clients/compose/compose-client.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { defaultComposeOptions } from "./default-compose-options";
44
import { ComposeDownOptions, ComposeOptions } from "./types";
55

66
export interface ComposeClient {
7+
version: string;
78
up(options: ComposeOptions, services?: Array<string>): Promise<void>;
89
pull(options: ComposeOptions, services?: Array<string>): Promise<void>;
910
stop(options: ComposeOptions): Promise<void>;
@@ -12,15 +13,18 @@ export interface ComposeClient {
1213

1314
export async function getComposeClient(environment: NodeJS.ProcessEnv): Promise<ComposeClient> {
1415
try {
15-
await compose.version();
16-
return new DockerComposeClient(environment);
16+
const version = (await compose.version()).data.version;
17+
return new DockerComposeClient(version, environment);
1718
} catch (err) {
18-
return new MissingComposeClient();
19+
return new MissingComposeClient("N/A");
1920
}
2021
}
2122

2223
class DockerComposeClient implements ComposeClient {
23-
constructor(private readonly environment: NodeJS.ProcessEnv) {}
24+
constructor(
25+
public readonly version: string,
26+
private readonly environment: NodeJS.ProcessEnv
27+
) {}
2428

2529
async up(options: ComposeOptions, services: Array<string> | undefined): Promise<void> {
2630
try {
@@ -90,7 +94,7 @@ class DockerComposeClient implements ComposeClient {
9094
}
9195

9296
class MissingComposeClient implements ComposeClient {
93-
public readonly info = undefined;
97+
constructor(public readonly version: string) {}
9498

9599
up(): Promise<void> {
96100
throw new Error("Compose is not installed");

packages/testcontainers/src/container-runtime/clients/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ export type ContainerRuntimeInfo = {
2525
labels: string[];
2626
};
2727

28-
export type ComposeInfo =
29-
| {
30-
version: string;
31-
compatability: "v1" | "v2";
32-
}
33-
| undefined;
28+
export type ComposeInfo = string;
3429

3530
export type HostIp = { address: string; family: number };

0 commit comments

Comments
 (0)