Skip to content

Commit a9df8b4

Browse files
committed
fix(CA): Set correct CA name
Signed-off-by: Liam Grace <[email protected]>
1 parent 0a8df62 commit a9df8b4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/nodes/ca.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ limitations under the License.
1313
*/
1414
import { Node } from './node';
1515
import { Container, ContainerInfo } from 'dockerode';
16+
import { executeCommand } from '../helpers';
1617

1718
export class CA extends Node {
1819
constructor(container: Container, containerInfo: ContainerInfo) {
@@ -21,7 +22,7 @@ export class CA extends Node {
2122

2223
async generateConfig() {
2324
const def: any = await super.generateConfig();
24-
def['ca_name'] = this.getContainerName();
25+
def['ca_name'] = await this.getCAName();
2526
return def;
2627
}
2728

@@ -32,6 +33,12 @@ export class CA extends Node {
3233
name = kebabToPascal(name);
3334
return name.substr(0, name.length - 1) + name.charAt(name.length - 1).toUpperCase();
3435
}
36+
37+
async getCAName() {
38+
const command = `echo -n $FABRIC_CA_SERVER_CA_NAME`;
39+
const result = await executeCommand(this.container, ['/bin/bash', '-c', command]);
40+
return result.toString('utf8').trim();
41+
}
3542
}
3643

3744
function kebabToPascal(str: string) {

src/nodes/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class Node {
8080

8181
isRunningLocally() {
8282
const addressInfo = this.getContainerAddress();
83-
if (addressInfo.indexOf('0.0.0.0') !== -1) {
83+
if (addressInfo.indexOf('0.0.0.0') !== -1 || addressInfo.indexOf('localhost') !== -1) {
8484
return true;
8585
} else {
8686
return false;

0 commit comments

Comments
 (0)