From 3e70dc465bc1ec7d03ceffd0ddc8c0235f329a17 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sun, 22 Sep 2019 14:32:48 +0200 Subject: [PATCH] fix(core): update --- ts/docker.classes.network.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ts/docker.classes.network.ts b/ts/docker.classes.network.ts index 77c97a1..c79a1e1 100644 --- a/ts/docker.classes.network.ts +++ b/ts/docker.classes.network.ts @@ -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 { @@ -91,16 +92,27 @@ export class DockerNetwork { const response = await this.dockerHost.request('DELETE', `/networks/${this.Id}`); } - public async getContainersOnNetwork(): Promise<{ - [key: string]: { + public async getContainersOnNetwork(): Promise { + }>> { + 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 getIpForService(serviceArg: DockerService) { + const containersOnNetwork = await this.getContainersOnNetwork(); + const containersOfService = containersOnNetwork.filter(container => { + return container.Name.startsWith(serviceArg.Spec.Name); + }); } }