From a9df8b4c3777f1aee17cc0f59c9306d6a7a75bc4 Mon Sep 17 00:00:00 2001 From: Liam Grace Date: Fri, 11 Oct 2019 11:40:09 +0100 Subject: [PATCH] fix(CA): Set correct CA name Signed-off-by: Liam Grace --- src/nodes/ca.ts | 9 ++++++++- src/nodes/node.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/nodes/ca.ts b/src/nodes/ca.ts index 651a318..552a0d6 100644 --- a/src/nodes/ca.ts +++ b/src/nodes/ca.ts @@ -13,6 +13,7 @@ limitations under the License. */ import { Node } from './node'; import { Container, ContainerInfo } from 'dockerode'; +import { executeCommand } from '../helpers'; export class CA extends Node { constructor(container: Container, containerInfo: ContainerInfo) { @@ -21,7 +22,7 @@ export class CA extends Node { async generateConfig() { const def: any = await super.generateConfig(); - def['ca_name'] = this.getContainerName(); + def['ca_name'] = await this.getCAName(); return def; } @@ -32,6 +33,12 @@ export class CA extends Node { name = kebabToPascal(name); return name.substr(0, name.length - 1) + name.charAt(name.length - 1).toUpperCase(); } + + async getCAName() { + const command = `echo -n $FABRIC_CA_SERVER_CA_NAME`; + const result = await executeCommand(this.container, ['/bin/bash', '-c', command]); + return result.toString('utf8').trim(); + } } function kebabToPascal(str: string) { diff --git a/src/nodes/node.ts b/src/nodes/node.ts index e9f5956..8ef7df4 100644 --- a/src/nodes/node.ts +++ b/src/nodes/node.ts @@ -80,7 +80,7 @@ export class Node { isRunningLocally() { const addressInfo = this.getContainerAddress(); - if (addressInfo.indexOf('0.0.0.0') !== -1) { + if (addressInfo.indexOf('0.0.0.0') !== -1 || addressInfo.indexOf('localhost') !== -1) { return true; } else { return false;