Repository navigation
feat (fabric-x): Simplify the Fabric-X configuration schema - #874
MaryamArif7 wants to merge 5 commits into
Conversation
Signed-off-by: MaryamArif7 <www.maryamarif28@gmail.com>
|
Tick the box to add this pull request to the merge queue (same as
|
|
Signed-off-by: MaryamArif7 <www.maryamarif28@gmail.com>
Signed-off-by: MaryamArif7 <www.maryamarif28@gmail.com>
Signed-off-by: MaryamArif7 <www.maryamarif28@gmail.com>
| "fabricVersion", | ||
| "tls" | ||
| ], | ||
| "required": [], |
There was a problem hiding this comment.
jsyk this makes these fields optional for classic Fabric too
I tested the schema after removing global.fabricVersion, global.tls, chaincodes and channels[0].orgs from a classic config, and it returned zero schema errors
The issue asks for provider-specific rules, so please keep the shared schema but use draft-07 if/then/else rules, compact requirements for provider: "fabric-x" and the existing requirements for classic Fabric.
cli only checks are not enough because editors and other tools consume schema.json directly
|
|
||
| const configContent = fs.readFileSync(this.fabloConfigPath, "utf-8"); | ||
| const networkConfig = parseFabloConfig(configContent); | ||
| const networkConfig = applyFabricXDefaults(parseFabloConfig(configContent)); |
There was a problem hiding this comment.
Please validate the config as written before applying defaults
Right now invalid values can be hidden by normalization, e.g "ca": null is replaced with the default ca and validation reports zero errors
removing orgs completely throws
TypeError: Cannot read properties of undefined (reading 'map')
before the schema can report the missing field, parse and validate the raw input first, stop semantic validation when its structure is invalid, and only then apply Fabric-X defaults
| import defaults from "./defaults"; | ||
|
|
||
|
|
||
| const applyFabricXDefaults = (json: FabloConfigJson | FabricXConfigJson): FabloConfigJson => { |
There was a problem hiding this comment.
I'd appreciate some unit tests for this normalizer and the provider specific schema rules, cover ommitted fabric-x defaults, explicit values being preserved, malformed values rejected and classic config still requiring it's existing fields
|
|
||
| let fabloConfigJson = flags.fabricX ? getDefaultFabricXConfig() : getDefaultFabloConfig(); | ||
| // the compact Fabric-X config is completed with defaults when it is read, so it is kept as written | ||
| let fabloConfigJson = flags.fabricX ? (getDefaultFabricXConfig() as FabloConfigJson) : getDefaultFabloConfig(); |
There was a problem hiding this comment.
This cast defeats the new compact config type
please type this value and the helper functions as FabloConfigJson | FabricXConfigJson instead
FabricXConfigJson.global.provider should also be the required literal "fabric-x" so typescript can distinguish the two input formats
| - `channels` does not hold exactly one channel | ||
| - `fabricX.orderer.partyCount` is not `1` or `4` | ||
|
|
||
| #### Compact Fabric-X config |
There was a problem hiding this comment.
“Compact” only makes sense relative to the old unreleased format
Just update the documentation with the new schema instead of this new section, not sure why users need to understand the simplification history when fabric-x on fablo hasn't released yet

fixes #873
What changed
How the defaults work
A small function (applyFabricXDefaults) fills in the missing values for fabric-x right after the config is read. It is used by validate and by extendConfig. Because of this, the generators and templates did not need to change. The orderer templates still loop over the parties, but that list is now built from partyCount.