refactor(packages/backend-common): allow supplying generic options to pull images
Signed-off-by: secustor <sebastian@poxhofer.at>
This commit is contained in:
@@ -305,20 +305,6 @@ export type DatabaseManagerOptions = {
|
||||
logger?: LoggerService;
|
||||
};
|
||||
|
||||
// @public
|
||||
export interface DockerAuthentication {
|
||||
// (undocumented)
|
||||
auth?: string;
|
||||
// (undocumented)
|
||||
email?: string;
|
||||
// (undocumented)
|
||||
password?: string;
|
||||
// (undocumented)
|
||||
serveraddress?: string;
|
||||
// (undocumented)
|
||||
username?: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class DockerContainerRunner implements ContainerRunner {
|
||||
constructor(options: { dockerClient: Docker });
|
||||
@@ -656,6 +642,21 @@ export { PluginDatabaseManager };
|
||||
|
||||
export { PluginEndpointDiscovery };
|
||||
|
||||
// @public
|
||||
export interface PullOptions {
|
||||
// (undocumented)
|
||||
[key: string]: unknown;
|
||||
// (undocumented)
|
||||
authconfig?: {
|
||||
username?: string;
|
||||
password?: string;
|
||||
auth?: string;
|
||||
email?: string;
|
||||
serveraddress?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
// @public
|
||||
export type ReaderFactory = (options: {
|
||||
config: Config;
|
||||
@@ -754,7 +755,7 @@ export type RunContainerOptions = {
|
||||
envVars?: Record<string, string>;
|
||||
pullImage?: boolean;
|
||||
defaultUser?: boolean;
|
||||
authentication?: DockerAuthentication;
|
||||
pullOptions?: PullOptions;
|
||||
};
|
||||
|
||||
export { SearchOptions };
|
||||
|
||||
@@ -23,12 +23,16 @@ import { Writable } from 'stream';
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface DockerAuthentication {
|
||||
username?: string;
|
||||
password?: string;
|
||||
auth?: string;
|
||||
email?: string;
|
||||
serveraddress?: string;
|
||||
export interface PullOptions {
|
||||
authconfig?: {
|
||||
username?: string;
|
||||
password?: string;
|
||||
auth?: string;
|
||||
email?: string;
|
||||
serveraddress?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +50,7 @@ export type RunContainerOptions = {
|
||||
envVars?: Record<string, string>;
|
||||
pullImage?: boolean;
|
||||
defaultUser?: boolean;
|
||||
authentication?: DockerAuthentication;
|
||||
pullOptions?: PullOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,8 +87,10 @@ describe('DockerContainerRunner', () => {
|
||||
await containerTaskApi.runContainer({
|
||||
imageName,
|
||||
args,
|
||||
authentication: {
|
||||
auth: 'aaaaaaaaa',
|
||||
pullOptions: {
|
||||
authconfig: {
|
||||
auth: 'aaaaaaaaa',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export class DockerContainerRunner implements ContainerRunner {
|
||||
envVars = {},
|
||||
pullImage = true,
|
||||
defaultUser = false,
|
||||
authentication,
|
||||
pullOptions = {},
|
||||
} = options;
|
||||
|
||||
// Show a better error message when Docker is unavailable.
|
||||
@@ -62,17 +62,13 @@ export class DockerContainerRunner implements ContainerRunner {
|
||||
|
||||
if (pullImage) {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
this.dockerClient.pull(
|
||||
imageName,
|
||||
{ authconfig: authentication },
|
||||
(err, stream) => {
|
||||
if (err) return reject(err);
|
||||
stream.pipe(logStream, { end: false });
|
||||
stream.on('end', () => resolve());
|
||||
stream.on('error', (error: Error) => reject(error));
|
||||
return undefined;
|
||||
},
|
||||
);
|
||||
this.dockerClient.pull(imageName, pullOptions, (err, stream) => {
|
||||
if (err) return reject(err);
|
||||
stream.pipe(logStream, { end: false });
|
||||
stream.on('end', () => resolve());
|
||||
stream.on('error', (error: Error) => reject(error));
|
||||
return undefined;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
export type {
|
||||
ContainerRunner,
|
||||
RunContainerOptions,
|
||||
DockerAuthentication,
|
||||
PullOptions,
|
||||
} from './ContainerRunner';
|
||||
export { DockerContainerRunner } from './DockerContainerRunner';
|
||||
export type {
|
||||
|
||||
Reference in New Issue
Block a user