Skip to content

Commit 38862c7

Browse files
authored
Merge branch 'main' into fabx_staticfeats
2 parents 723efb3 + 96f9131 commit 38862c7

8 files changed

Lines changed: 100 additions & 2 deletions

File tree

docs/schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@
109109
],
110110
"default": "docker"
111111
},
112+
"provider": {
113+
"$id": "#/properties/global/properties/provider",
114+
"title": "Network provider (EXPERIMENTAL)",
115+
"description": "Selects the network provider. 'fabric' is the default and fully supported. 'fabric-x' is experimental",
116+
"type": "string",
117+
"enum": [
118+
"fabric",
119+
"fabric-x"
120+
],
121+
"default": "fabric"
122+
},
123+
112124
"monitoring": {
113125
"$id": "#/properties/monitoring",
114126
"title": "Monitoring settings",

e2e/__snapshots__/extendConfig.test.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ exports[`extend config samples/fablo-config-hlf2-1org-1chaincode.json 1`] = `
612612
"fabloConfig": "<absolute path>",
613613
},
614614
"peerImage": "hyperledger/fabric-peer:2.5.9",
615+
"provider": "fabric",
615616
"tls": false,
616617
"tools": {},
617618
"toolsImage": "hyperledger/fabric-tools:2.5.9",
@@ -1449,6 +1450,7 @@ exports[`extend config samples/fablo-config-hlf2-1org-1chaincode-k8s.json 1`] =
14491450
"fabloConfig": "<absolute path>",
14501451
},
14511452
"peerImage": "hyperledger/fabric-peer:2.4.7",
1453+
"provider": "fabric",
14521454
"tls": false,
14531455
"tools": {},
14541456
"toolsImage": "hyperledger/fabric-tools:2.4.7",
@@ -2262,6 +2264,7 @@ exports[`extend config samples/fablo-config-hlf2-1org-1chaincode-peer-dev-mode.j
22622264
},
22632265
"peerDevMode": true,
22642266
"peerImage": "hyperledger/fabric-peer:2.5.12",
2267+
"provider": "fabric",
22652268
"tls": false,
22662269
"tools": {},
22672270
"toolsImage": "hyperledger/fabric-tools:2.5.12",
@@ -3640,6 +3643,7 @@ exports[`extend config samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.
36403643
"fabloConfig": "<absolute path>",
36413644
},
36423645
"peerImage": "hyperledger/fabric-peer:2.5.12",
3646+
"provider": "fabric",
36433647
"tls": false,
36443648
"tools": {},
36453649
"toolsImage": "hyperledger/fabric-tools:2.5.12",
@@ -5926,6 +5930,7 @@ exports[`extend config samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml 1`]
59265930
"fabloConfig": "<absolute path>",
59275931
},
59285932
"peerImage": "hyperledger/fabric-peer:2.5.12",
5933+
"provider": "fabric",
59295934
"tls": true,
59305935
"tools": {
59315936
"explorer": {
@@ -8531,6 +8536,7 @@ exports[`extend config samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.
85318536
"fabloConfig": "<absolute path>",
85328537
},
85338538
"peerImage": "hyperledger/fabric-peer:2.3.2",
8539+
"provider": "fabric",
85348540
"tls": true,
85358541
"tools": {
85368542
"explorer": {
@@ -10395,6 +10401,7 @@ exports[`extend config samples/fablo-config-hlf3-1org-2chaincode-raft-ccaas.json
1039510401
"fabloConfig": "<absolute path>",
1039610402
},
1039710403
"peerImage": "hyperledger/fabric-peer:3.1.0",
10404+
"provider": "fabric",
1039810405
"tls": true,
1039910406
"tools": {},
1040010407
"toolsImage": "ghcr.io/fablo-io/fabric-tools:3.1.3",
@@ -11663,6 +11670,7 @@ exports[`extend config samples/fablo-config-hlf3-1orgs-2chaincodes.json 1`] = `
1166311670
"fabloConfig": "<absolute path>",
1166411671
},
1166511672
"peerImage": "hyperledger/fabric-peer:3.1.0",
11673+
"provider": "fabric",
1166611674
"tls": true,
1166711675
"tools": {},
1166811676
"toolsImage": "ghcr.io/fablo-io/fabric-tools:3.1.3",
@@ -12724,6 +12732,7 @@ exports[`extend config samples/fablo-config-hlf3-2orgs-1chaincode-raft-ccaas.jso
1272412732
"fabloConfig": "<absolute path>",
1272512733
},
1272612734
"peerImage": "hyperledger/fabric-peer:3.1.0",
12735+
"provider": "fabric",
1272712736
"tls": true,
1272812737
"tools": {},
1272912738
"toolsImage": "ghcr.io/fablo-io/fabric-tools:3.1.3",
@@ -13704,6 +13713,7 @@ exports[`extend config samples/fablo-config-hlf3-bft-1orgs-1chaincode.json 1`] =
1370413713
"fabloConfig": "<absolute path>",
1370513714
},
1370613715
"peerImage": "hyperledger/fabric-peer:3.1.0",
13716+
"provider": "fabric",
1370713717
"tls": true,
1370813718
"tools": {},
1370913719
"toolsImage": "ghcr.io/fablo-io/fabric-tools:3.1.3",
@@ -15154,6 +15164,7 @@ exports[`extend config samples/invalid-fablo-config.json 1`] = `
1515415164
"fabloConfig": "<absolute path>",
1515515165
},
1515615166
"peerImage": "hyperledger/fabric-peer:3.1.0",
15167+
"provider": "fabric",
1515715168
"tls": true,
1515815169
"tools": {},
1515915170
"toolsImage": "ghcr.io/fablo-io/fabric-tools:3.1.3",
@@ -15867,6 +15878,7 @@ exports[`extend config samples/java-dev-mode-sample.json 1`] = `
1586715878
},
1586815879
"peerDevMode": true,
1586915880
"peerImage": "hyperledger/fabric-peer:2.4.3",
15881+
"provider": "fabric",
1587015882
"tls": false,
1587115883
"tools": {},
1587215884
"toolsImage": "hyperledger/fabric-tools:2.4.3",

e2e/__snapshots__/fabloCommands.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ exports[`extend config should extend custom config 1`] = `
2727
"javaenvImage": "hyperledger/fabric-javaenv:2.5",
2828
"nodeenvImage": "hyperledger/fabric-nodeenv:2.5",
2929
"engine": "docker",
30+
"provider": "fabric",
3031
"paths": {
3132
"fabloConfig": "<absolute path>",
3233
"chaincodesBaseDir": "<absolute path>"
@@ -2513,6 +2514,7 @@ exports[`extend config should extend default config 1`] = `
25132514
"baseosImage": "hyperledger/fabric-baseos:3.1.0",
25142515
"javaenvImage": "hyperledger/fabric-javaenv:2.5",
25152516
"nodeenvImage": "hyperledger/fabric-nodeenv:2.5",
2517+
"provider": "fabric",
25162518
"paths": {
25172519
"fabloConfig": "<absolute path>",
25182520
"chaincodesBaseDir": "<absolute path>"

e2e/__snapshots__/schema.test.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,17 @@ exports[`schema should match snapshot 1`] = `
364364
"title": "Start all peers in dev mode",
365365
"type": "boolean",
366366
},
367+
"provider": {
368+
"$id": "#/properties/global/properties/provider",
369+
"default": "fabric",
370+
"description": "Selects the network provider. 'fabric' is the default and fully supported. 'fabric-x' is experimental",
371+
"enum": [
372+
"fabric",
373+
"fabric-x",
374+
],
375+
"title": "Network provider (EXPERIMENTAL)",
376+
"type": "string",
377+
},
367378
"tls": {
368379
"$id": "#/properties/global/properties/tls",
369380
"default": true,

src/commands/validate/index.ts

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,17 @@ export default class Validate extends Command {
116116

117117
const configContent = fs.readFileSync(this.fabloConfigPath, "utf-8");
118118
const networkConfig = parseFabloConfig(configContent);
119+
const provider = networkConfig.global.provider ?? "fabric";
120+
119121
this._validateFabricVersion(networkConfig.global);
120-
networkConfig.chaincodes.forEach((chaincode) => this._validateCcaaTLS(networkConfig.global, chaincode));
121122
this._validateJsonSchema(networkConfig);
122123
this._validateSupportedFabloVersion(networkConfig.$schema);
124+
125+
if (provider === "fabric-x") {
126+
this._validateFabricXSettings(networkConfig);
127+
return;
128+
}
129+
networkConfig.chaincodes.forEach((chaincode) => this._validateCcaaTLS(networkConfig.global, chaincode));
123130
this._validateOrgs(networkConfig.orgs);
124131
this._validateEngineSpecificSettings(networkConfig);
125132

@@ -525,7 +532,58 @@ export default class Validate extends Command {
525532

526533
// TODO engine-specific validation rules
527534
}
535+
_validateFabricXSettings(networkConfig: FabloConfigJson): void {
536+
const { global, chaincodes, channels, orgs } = networkConfig;
537+
538+
if (global.engine === "kubernetes") {
539+
this.emit(validationErrorType.ERROR, {
540+
category: validationCategories.GENERAL,
541+
message: "fabric-x does not support the 'kubernetes' engine .Use 'docker'",
542+
});
543+
}
544+
545+
if (!global.tls) {
546+
this.emit(validationErrorType.ERROR, {
547+
category: validationCategories.GENERAL,
548+
message: "fabric-x requires 'global.tls' to be true.",
549+
});
550+
}
528551

552+
if (global.peerDevMode) {
553+
this.emit(validationErrorType.ERROR, {
554+
category: validationCategories.GENERAL,
555+
message: "fabric-x requires 'global.peerDevMode' to be false.",
556+
});
557+
}
558+
559+
if (global.tools?.explorer === true || orgs.some((o) => o.tools?.explorer === true)) {
560+
this.emit(validationErrorType.ERROR, {
561+
category: validationCategories.GENERAL,
562+
message: "Explorer is not supported for fabric-x.",
563+
});
564+
}
565+
566+
if (orgs.some((o) => o.tools?.fabloRest === true)) {
567+
this.emit(validationErrorType.ERROR, {
568+
category: validationCategories.GENERAL,
569+
message: "Fablo REST is not supported for provider fabric-x.",
570+
});
571+
}
572+
573+
if (chaincodes.length > 0) {
574+
this.emit(validationErrorType.ERROR, {
575+
category: validationCategories.CHAINCODE,
576+
message: "fabric-x does not support chaincodes in this PoC.",
577+
});
578+
}
579+
580+
if (channels.length !== 1) {
581+
this.emit(validationErrorType.ERROR, {
582+
category: validationCategories.CHANNEL,
583+
message: `fabric-x requires exactly one channel found ${channels.length}.`,
584+
});
585+
}
586+
}
529587
_validateExplorer(global: GlobalJson, orgs: OrgJson[]): void {
530588
if (global.tools?.explorer === true) {
531589
orgs

src/extend-config/extendGlobal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const extendGlobal = (globalJson: GlobalJson): Global => {
9292
const versions = getVersions(globalJson.fabricVersion);
9393
const images = getImages(globalJson.fabricVersion, versions, fabricImages);
9494
const engine = globalJson.engine ?? "docker";
95-
95+
const provider = globalJson.provider ?? "fabric";
9696
const monitoring = {
9797
loglevel: globalJson?.monitoring?.loglevel || defaults.global.monitoring.loglevel,
9898
};
@@ -113,6 +113,7 @@ const extendGlobal = (globalJson: GlobalJson): Global => {
113113
...versions,
114114
...images,
115115
engine,
116+
provider,
116117
paths,
117118
monitoring,
118119
capabilities: getNetworkCapabilities(globalJson.fabricVersion),

src/types/FabloConfigExtended.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export type Capabilities = CapabilitiesV2 | CapabilitiesV_2_5 | CapabilitiesV3_0
4949
export interface Global extends FabricVersions, FabricImages {
5050
tls: boolean;
5151
engine: "kubernetes" | "docker";
52+
provider: "fabric" | "fabric-x";
5253
monitoring: { loglevel: string };
5354
paths: { fabloConfig: string; chaincodesBaseDir: string };
5455
capabilities: Capabilities;

src/types/FabloConfigJson.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface GlobalJson {
44
peerDevMode: boolean;
55
fabricImages?: FabricImagesJson;
66
engine?: "kubernetes" | "docker";
7+
provider?: "fabric" | "fabric-x";
78
monitoring?: { loglevel: string };
89
tools?: { explorer?: boolean };
910
}

0 commit comments

Comments
 (0)