Skip to content

Commit

Permalink
fix(CA): Set correct CA name
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Grace <[email protected]>
  • Loading branch information
liam-grace committed Oct 11, 2019
1 parent 0a8df62 commit a9df8b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/nodes/ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a9df8b4

Please sign in to comment.