Compare commits

...

6 Commits

Author SHA1 Message Date
eaaf313442 1.1.3 2024-06-06 00:25:40 +02:00
68b2baadae fix(core): update 2024-06-06 00:25:39 +02:00
6743dc35e7 1.1.2 2024-06-06 00:14:31 +02:00
bbf265716d fix(core): update 2024-06-06 00:14:30 +02:00
3a705534fe 1.1.1 2024-06-05 23:56:03 +02:00
cbdbd32dd1 fix(core): update 2024-06-05 23:56:02 +02:00
6 changed files with 18 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@apiclient.xyz/docker",
"version": "1.1.0",
"version": "1.1.3",
"description": "Provides easy communication with Docker remote API from Node.js, with TypeScript support.",
"private": false,
"main": "dist_ts/index.js",

View File

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

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/docker',
version: '1.1.0',
version: '1.1.3',
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 { logger } from './logging.js';
import path from 'path';
import type { DockerImageStore } from './classes.imagestore.js';
export interface IAuthData {
serveraddress: string;
@ -11,21 +12,27 @@ export interface IAuthData {
password: string;
}
export interface IDockerHostConstructorOptions {
dockerSockPath?: string;
imageStoreDir?: string;
}
export class DockerHost {
/**
* the path where the docker sock can be found
*/
public socketPath: string;
private registryToken: string = '';
public imageStore: DockerImageStore;
/**
* the constructor to instantiate a new docker sock instance
* @param pathArg
*/
constructor(pathArg?: string) {
constructor(optionsArg: IDockerHostConstructorOptions) {
let pathToUse: string;
if (pathArg) {
pathToUse = pathArg;
if (optionsArg.dockerSockPath) {
pathToUse = optionsArg.dockerSockPath;
} else if (process.env.DOCKER_HOST) {
pathToUse = process.env.DOCKER_HOST;
} else if (process.env.CI) {

View File

@ -1,5 +1,6 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import type { DockerHost } from './classes.host.js';
export interface IDockerImageStoreConstructorOptions {
dirPath: string;
@ -8,12 +9,12 @@ export interface IDockerImageStoreConstructorOptions {
export class DockerImageStore {
public options: IDockerImageStoreConstructorOptions;
constructor(optionsArg: IDockerImageStoreConstructorOptions) {
constructor(dockerHost: DockerHost, optionsArg: IDockerImageStoreConstructorOptions) {
this.options = optionsArg;
}
// Method to store tar stream
public async storeImage(imageName: string, tarStream: NodeJS.ReadableStream): Promise<void> {
public async storeImage(imageName: string, tarStream: plugins.smartstream.stream.Readable): Promise<void> {
const imagePath = plugins.path.join(this.options.dirPath, `${imageName}.tar`);
// Create a write stream to store the tar file

View File

@ -1,6 +1,7 @@
export * from './classes.host.js';
export * from './classes.container.js';
export * from './classes.image.js';
export * from './classes.imagestore.js';
export * from './classes.network.js';
export * from './classes.secret.js';
export * from './classes.service.js';