Compare commits

...

4 Commits

Author SHA1 Message Date
3f18cb68bf 1.0.77 2019-09-22 15:02:29 +02:00
dae3b59e3b fix(core): update 2019-09-22 15:02:29 +02:00
53062e70d4 1.0.76 2019-09-22 14:32:48 +02:00
3e70dc465b fix(core): update 2019-09-22 14:32:48 +02:00
3 changed files with 20 additions and 7 deletions

2
package-lock.json generated
View File

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

View File

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

View File

@ -2,6 +2,7 @@ import * as plugins from './docker.plugins';
import * as interfaces from './interfaces';
import { DockerHost } from './docker.classes.host';
import { DockerService } from './docker.classes.service';
export class DockerNetwork {
public static async getNetworks(dockerHost: DockerHost): Promise<DockerNetwork[]> {
@ -91,16 +92,28 @@ export class DockerNetwork {
const response = await this.dockerHost.request('DELETE', `/networks/${this.Id}`);
}
public async getContainersOnNetwork(): Promise<{
[key: string]: {
public async getContainersOnNetwork(): Promise<Array<{
Name: string;
EndpointID: string;
MacAddress: string;
IPv4Address: string;
IPv6Address: string;
};
}> {
}>> {
const returnArray = [];
const response = await this.dockerHost.request('GET', `/networks/${this.Id}`);
return response.body.Containers;
for (const key of Object.keys(response.body.Containers)) {
returnArray.push(response.body.Containers[key]);
}
return returnArray;
}
public async getContainersOnNetworkForService(serviceArg: DockerService) {
const containersOnNetwork = await this.getContainersOnNetwork();
const containersOfService = containersOnNetwork.filter(container => {
return container.Name.startsWith(serviceArg.Spec.Name);
});
return containersOnNetwork;
}
}