Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/setup-docker/fabricXDockerWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@ import { renderTemplate, getTemplatePath, getDestinationPath } from "../utils/te
import * as fs from "fs-extra";
import * as path from "path";

export interface FabricXTemplateModel {
channelName: string;
channelProfileName: string;
}
Comment thread
umegbewe marked this conversation as resolved.

export const getFabricXTemplateModel = (configExtended: FabloConfigExtended): FabricXTemplateModel => {
const [channel] = configExtended.channels;
if (!channel) {
throw new Error("Fabric-X generation requires exactly one channel.");
}
return {
channelName: channel.name,
channelProfileName: channel.profileName,
};
};
Comment thread
MaryamArif7 marked this conversation as resolved.

export class FabricXDockerWriter {

constructor(private templatesDir: string, private outputDir: string, private log: (msg: string) => void) {}

public async write(configExtended: FabloConfigExtended): Promise<void> {
this.log("Generating Fabric-X network files...");

const data = configExtended as unknown as Record<string, unknown>;
const fabricX = getFabricXTemplateModel(configExtended);
const data = { ...configExtended, fabricX } as unknown as Record<string, unknown>;

await this.renderTemplateFile("fabric-x-docker.sh", data);
await this.renderTemplateDirectory("fabric-x", data);
Expand Down
2 changes: 1 addition & 1 deletion src/setup-docker/templates/fabric-x/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Channel: &ChannelDefaults
<<: *ChannelCapabilities

Profiles:
OrgsChannel:
<%- fabricX.channelProfileName %>:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
Expand Down
2 changes: 1 addition & 1 deletion src/setup-docker/templates/fabric-x/fxconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msp:

orderer:
address: orderer-router:7050
channel: mychannel
channel: <%- fabricX.channelName %>
tls:
enabled: true
clientCert: /tls/server.crt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ generateArtifacts() {
docker run --rm --user "$(id -u):$(id -g)" \
-v "$FABRIC_X_ROOT:/config" \
"$TOOLS_IMAGE" \
configtxgen --channelID mychannel --profile OrgsChannel \
configtxgen --channelID <%- fabricX.channelName %> --profile <%- fabricX.channelProfileName %> \
--outputBlock /config/crypto/config-block.pb.bin \
--configPath /config

Expand Down
Loading