Compare commits

...

10 Commits

Author SHA1 Message Date
65c37bdd6f 1.0.49 2019-08-16 21:21:31 +02:00
6acbe30e2e fix(core): update 2019-08-16 21:21:30 +02:00
eb6f7889d0 1.0.48 2019-08-16 21:10:03 +02:00
e39da5fee9 fix(core): update 2019-08-16 21:10:03 +02:00
b07628bb0b 1.0.47 2019-08-16 21:07:59 +02:00
5815f9b202 fix(core): update 2019-08-16 21:07:59 +02:00
846ea9997e 1.0.46 2019-08-16 18:32:42 +02:00
de54db33ad fix(core): update 2019-08-16 18:32:41 +02:00
314cb692ac 1.0.45 2019-08-16 18:21:55 +02:00
73f8ded3fe fix(core): update 2019-08-16 18:21:55 +02:00
8 changed files with 41 additions and 17 deletions

View File

@ -48,7 +48,7 @@ testLTS:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv - priv
testBuild: testBuild:
stage: test stage: test

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/docker", "name": "@mojoio/docker",
"version": "1.0.44", "version": "1.0.49",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/docker", "name": "@mojoio/docker",
"version": "1.0.44", "version": "1.0.49",
"description": "easy communication with docker remote api from node, TypeScript ready", "description": "easy communication with docker remote api from node, TypeScript ready",
"private": false, "private": false,
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -64,12 +64,17 @@ tap.test('should list all services', async tools => {
}); });
tap.test('should create a service', async () => { tap.test('should create a service', async () => {
const testNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, {
Name: 'testNetwork'
});
await DockerService.createService(testDockerHost, { await DockerService.createService(testDockerHost, {
Image: 'nginx', Image: 'nginx:latest',
Labels: { Labels: {
'testlabel': 'hi' 'testlabel': 'hi'
}, },
Name: 'testService' Name: 'testService',
networks: [testNetwork],
networkAlias: 'testService'
}); });
}); });

View File

@ -12,8 +12,16 @@ export class DockerHost {
* 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 = 'http://unix:/var/run/docker.sock:') { constructor(pathArg?: string) {
this.socketPath = pathArg; let pathToUse: string;
if (pathArg) {
pathToUse = pathArg;
} else if (process.env.CI) {
pathToUse = 'tcp://docker:2375/';
} else {
pathToUse = 'http://unix:/var/run/docker.sock:';
}
this.socketPath = pathToUse;
} }
/** /**

View File

@ -47,6 +47,8 @@ export class DockerImage {
} else { } else {
imageUrlObject.imageTag = imageTag; imageUrlObject.imageTag = imageTag;
} }
} else if (!imageUrlObject.imageTag) {
imageUrlObject.imageTag = 'latest';
} }
imageUrlObject.imageOriginTag = `${imageUrlObject.imageUrl}:${imageUrlObject.imageTag}`; imageUrlObject.imageOriginTag = `${imageUrlObject.imageUrl}:${imageUrlObject.imageTag}`;
@ -110,14 +112,6 @@ export class DockerImage {
}); });
} }
/**
* returns a boolean wether the image has a upstream image
*/
public isUpstreamImage(): boolean {
// TODO: implement isUpastreamImage
return this.RepoTags.length > 0;
}
public tagImage(newTag) {} public tagImage(newTag) {}
/** /**

View File

@ -23,10 +23,19 @@ export class DockerService {
serviceCreationDescriptor: interfaces.IServiceCreationDescriptor serviceCreationDescriptor: interfaces.IServiceCreationDescriptor
) { ) {
// lets get the image // lets get the image
DockerImage.createFromRegistry(dockerHost, { plugins.smartlog.defaultLogger.log('info', `downloading image for service ${serviceCreationDescriptor.Name}`);
const serviceImage = await DockerImage.createFromRegistry(dockerHost, {
imageUrl: serviceCreationDescriptor.Image imageUrl: serviceCreationDescriptor.Image
}); });
const networkArray: any[] = [];
for (const network of serviceCreationDescriptor.networks) {
networkArray.push({
Target: network.Name,
Aliases: [serviceCreationDescriptor.networkAlias]
});
}
dockerHost.request('POST', '/services/create', { dockerHost.request('POST', '/services/create', {
Name: serviceCreationDescriptor.Name, Name: serviceCreationDescriptor.Name,
TaskTemplate: { TaskTemplate: {
@ -35,7 +44,8 @@ export class DockerService {
Labels: serviceCreationDescriptor.Labels Labels: serviceCreationDescriptor.Labels
} }
}, },
Labels: serviceCreationDescriptor.Labels Labels: serviceCreationDescriptor.Labels,
Networks: networkArray
}); });
} }
@ -46,4 +56,8 @@ export class DockerService {
this.dockerHost = dockerHostArg; this.dockerHost = dockerHostArg;
Object.assign(this, serviceObject); Object.assign(this, serviceObject);
} }
update() {
// TODO: implemnt updating service
}
} }

View File

@ -1,7 +1,10 @@
import * as interfaces from './'; import * as interfaces from './';
import { DockerNetwork } from '../docker.classes.network';
export interface IServiceCreationDescriptor { export interface IServiceCreationDescriptor {
Name: string; Name: string;
Image: string; Image: string;
Labels: interfaces.TLabels; Labels: interfaces.TLabels;
networks: DockerNetwork[];
networkAlias: string;
} }