Compare commits

...

4 Commits

Author SHA1 Message Date
49445d93c6 1.0.75 2019-09-21 21:57:57 +02:00
4f838837f8 fix(core): update 2019-09-21 21:57:57 +02:00
c76968bbe8 1.0.74 2019-09-20 16:29:44 +02:00
6c5e5644b1 fix(core): update 2019-09-20 16:29:43 +02:00
6 changed files with 26 additions and 11 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/docker", "name": "@mojoio/docker",
"version": "1.0.73", "version": "1.0.75",
"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.73", "version": "1.0.75",
"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

@ -87,24 +87,22 @@ tap.test('should create a service', async () => {
Name: 'testNetwork' Name: 'testNetwork'
}); });
const testSecret = await docker.DockerSecret.createSecret(testDockerHost, { const testSecret = await docker.DockerSecret.createSecret(testDockerHost, {
name: 'serviceSecret', name: 'testSecret',
version: '0.0.1', version: '0.0.1',
labels: {}, labels: {},
contentArg: '{"hi": "wow"}' contentArg: '{"hi": "wow"}'
}); });
const testImage = await docker.DockerImage.createFromRegistry(testDockerHost, { const testImage = await docker.DockerImage.createFromRegistry(testDockerHost, {
imageUrl: 'nginx:latest' imageUrl: 'registry.gitlab.com/hosttoday/ht-docker-static'
}); });
const testService = await docker.DockerService.createService(testDockerHost, { const testService = await docker.DockerService.createService(testDockerHost, {
image: testImage, image: testImage,
labels: { labels: {},
testlabel: 'hi'
},
name: 'testService', name: 'testService',
networks: [testNetwork], networks: [testNetwork],
networkAlias: 'testService', networkAlias: 'testService',
secrets: [testSecret], secrets: [testSecret],
ports: [] ports: ['3000:80']
}); });
await testService.remove(); await testService.remove();

View File

@ -137,6 +137,10 @@ export class DockerImage {
// get stuff // get stuff
public async getVersion() { public async getVersion() {
return this.Labels.version; if (this.Labels && this.Labels.version) {
return this.Labels.version;
} else {
return 'x.x.x';
}
} }
} }

View File

@ -90,4 +90,17 @@ export class DockerNetwork {
public async remove() { public async remove() {
const response = await this.dockerHost.request('DELETE', `/networks/${this.Id}`); const response = await this.dockerHost.request('DELETE', `/networks/${this.Id}`);
} }
public async getContainersOnNetwork(): Promise<{
[key: string]: {
Name: string;
EndpointID: string;
MacAddress: string;
IPv4Address: string;
IPv6Address: string;
};
}> {
const response = await this.dockerHost.request('GET', `/networks/${this.Id}`);
return response.body.Containers;
}
} }

View File

@ -92,8 +92,8 @@ export class DockerService {
const containerPort = portArray[1]; const containerPort = portArray[1];
ports.push({ ports.push({
Protocol: 'tcp', Protocol: 'tcp',
PublishedPort: parseInt(containerPort, 10), PublishedPort: parseInt(hostPort, 10),
TargetPort: parseInt(hostPort, 10) TargetPort: parseInt(containerPort, 10)
}); });
} }