fix(core): update

This commit is contained in:
Philipp Kunz 2024-06-05 23:56:02 +02:00
parent 224004217c
commit cbdbd32dd1
4 changed files with 15 additions and 7 deletions

View File

@ -8,7 +8,7 @@ import * as docker from '../ts/index.js';
let testDockerHost: docker.DockerHost; let testDockerHost: docker.DockerHost;
tap.test('should create a new Dockersock instance', async () => { tap.test('should create a new Dockersock instance', async () => {
testDockerHost = new docker.DockerHost(); testDockerHost = new docker.DockerHost({});
return expect(testDockerHost).toBeInstanceOf(docker.DockerHost); return expect(testDockerHost).toBeInstanceOf(docker.DockerHost);
}); });
@ -118,7 +118,7 @@ tap.test('should create a service', async () => {
await testSecret.remove(); await testSecret.remove();
}); });
tap.skip.test('should export images', async (toolsArg) => { tap.test('should export images', async (toolsArg) => {
const done = toolsArg.defer(); const done = toolsArg.defer();
const testImage = await docker.DockerImage.createFromRegistry(testDockerHost, { const testImage = await docker.DockerImage.createFromRegistry(testDockerHost, {
creationObject: { creationObject: {

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@apiclient.xyz/docker', name: '@apiclient.xyz/docker',
version: '1.1.0', version: '1.1.1',
description: 'Provides easy communication with Docker remote API from Node.js, with TypeScript support.' description: 'Provides easy communication with Docker remote API from Node.js, with TypeScript support.'
} }

View File

@ -4,6 +4,7 @@ import { DockerNetwork } from './classes.network.js';
import { DockerService } from './classes.service.js'; import { DockerService } from './classes.service.js';
import { logger } from './logging.js'; import { logger } from './logging.js';
import path from 'path'; import path from 'path';
import type { DockerImageStore } from './classes.imagestore.js';
export interface IAuthData { export interface IAuthData {
serveraddress: string; serveraddress: string;
@ -11,21 +12,27 @@ export interface IAuthData {
password: string; password: string;
} }
export interface IDockerHostConstructorOptions {
dockerSockPath?: string;
imageStoreDir?: string;
}
export class DockerHost { export class DockerHost {
/** /**
* the path where the docker sock can be found * the path where the docker sock can be found
*/ */
public socketPath: string; public socketPath: string;
private registryToken: string = ''; private registryToken: string = '';
public imageStore: DockerImageStore;
/** /**
* the constructor to instantiate a new docker sock instance * the constructor to instantiate a new docker sock instance
* @param pathArg * @param pathArg
*/ */
constructor(pathArg?: string) { constructor(optionsArg: IDockerHostConstructorOptions) {
let pathToUse: string; let pathToUse: string;
if (pathArg) { if (optionsArg.dockerSockPath) {
pathToUse = pathArg; pathToUse = optionsArg.dockerSockPath;
} else if (process.env.DOCKER_HOST) { } else if (process.env.DOCKER_HOST) {
pathToUse = process.env.DOCKER_HOST; pathToUse = process.env.DOCKER_HOST;
} else if (process.env.CI) { } else if (process.env.CI) {

View File

@ -1,5 +1,6 @@
import * as plugins from './plugins.js'; import * as plugins from './plugins.js';
import * as paths from './paths.js'; import * as paths from './paths.js';
import type { DockerHost } from './classes.host.js';
export interface IDockerImageStoreConstructorOptions { export interface IDockerImageStoreConstructorOptions {
dirPath: string; dirPath: string;
@ -8,7 +9,7 @@ export interface IDockerImageStoreConstructorOptions {
export class DockerImageStore { export class DockerImageStore {
public options: IDockerImageStoreConstructorOptions; public options: IDockerImageStoreConstructorOptions;
constructor(optionsArg: IDockerImageStoreConstructorOptions) { constructor(dockerHost: DockerHost, optionsArg: IDockerImageStoreConstructorOptions) {
this.options = optionsArg; this.options = optionsArg;
} }