Skip to content

Commit e243e99

Browse files
Pass in new fields in RegistryConfig when image is built
1 parent e5e0b25 commit e243e99

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

packages/testcontainers/src/generic-container/generic-container-builder.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import type { ImageBuildOptions } from "dockerode";
22
import path from "path";
33
import { log, RandomUuid, Uuid } from "../common";
44
import { getAuthConfig, getContainerRuntimeClient, ImageName } from "../container-runtime";
5+
import { AuthConfig } from "../container-runtime/auth/types";
56
import { getReaper } from "../reaper/reaper";
6-
import { AuthConfig, BuildArgs, RegistryConfig } from "../types";
7+
import { BuildArgs, RegistryConfig } from "../types";
78
import { getDockerfileImages } from "../utils/dockerfile-parser";
89
import { createLabels, LABEL_TESTCONTAINERS_SESSION_ID } from "../utils/labels";
910
import { ImagePullPolicy, PullPolicy } from "../utils/pull-policy";
@@ -81,6 +82,7 @@ export class GenericContainerBuilder {
8182
dockerfile: this.dockerfileName,
8283
buildargs: this.buildArgs,
8384
nocache: !this.cache,
85+
// @ts-expect-error Dockerode types don't yet include identityToken
8486
registryconfig: registryConfig,
8587
labels,
8688
target: this.target,
@@ -115,14 +117,7 @@ export class GenericContainerBuilder {
115117
);
116118

117119
return authConfigs
118-
.map((authConfig) => {
119-
return {
120-
[authConfig.registryAddress]: {
121-
username: authConfig.username,
122-
password: authConfig.password,
123-
},
124-
};
125-
})
120+
.map((authConfig) => ({ [authConfig.registryAddress]: authConfig }))
126121
.reduce((prev, next) => ({ ...prev, ...next }), {} as RegistryConfig);
127122
}
128123
}

packages/testcontainers/src/types.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Readable } from "stream";
2+
import { AuthConfig } from "./container-runtime/auth/types";
23
import { ContainerCommitOptions } from "./container-runtime/clients/container/types";
34

45
export type InspectResult = {
@@ -71,18 +72,8 @@ export type Labels = { [key: string]: string };
7172
export type HostPortBindings = Array<{ hostIp: string; hostPort: number }>;
7273
export type Ports = { [containerPortWithProtocol: string]: HostPortBindings };
7374

74-
export type AuthConfig = {
75-
username: string;
76-
password: string;
77-
registryAddress: string;
78-
email?: string;
79-
};
80-
8175
export type RegistryConfig = {
82-
[registryAddress: string]: {
83-
username: string;
84-
password: string;
85-
};
76+
[registryAddress: string]: AuthConfig;
8677
};
8778

8879
export type BuildArgs = { [key in string]: string };

0 commit comments

Comments
 (0)