Skip to content

feat(cli): add support for dynamic configuration overrides in init command #444#732

Open
HarK-github wants to merge 18 commits into
hyperledger-labs:mainfrom
HarK-github:issue444
Open

feat(cli): add support for dynamic configuration overrides in init command #444#732
HarK-github wants to merge 18 commits into
hyperledger-labs:mainfrom
HarK-github:issue444

Conversation

@HarK-github

@HarK-github HarK-github commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Add Support for Dynamic Configuration Overrides in fablo init

This PR introduces the ability to override any property in the default fablo-config.json directly from the CLI during fablo init using the --set flag.

1. New --set Flag

  • Users can now override configuration values using --set key=value syntax
  • Supports multiple --set flags in a single command
  • Example: fablo init --set global.fabricVersion=2.5.0 --set global.tls=false

2. Smart Type Casting

The parser automatically detects and converts values to appropriate types:

  • Booleans: true/false → boolean type
  • Numbers: 5, 3.14 → number type
  • JSON: {"key":"value"}, [1,2,3] → object/array type
  • Strings: All other values → string type

3. Nested Path Support

  • Supports dot notation for nested objects: global.monitoring.loglevel=debug
  • Supports array indexing: orgs[0].peer.db=CouchDb
  • Auto-creates non-existent nested paths

4. Backward Compatibility

  • Preserves existing node, dev, ccaas, gateway, rest positional arguments
  • Existing workflows continue to work without changes
  • Command signature unchanged

5. E2E Test Coverage

Added comprehensive test coverage for:

  • Numeric string coercion (ensures numbers, not strings)
  • Non-existent nested path creation
  • Multiple simultaneous overrides with mixed types
  • Boolean, string, and array overrides

Usage Examples:

# Single override
fablo init --set global.fabricVersion=2.5.0

# Multiple overrides
fablo init --set global.tls=false --set orgs[0].peer.db=CouchDb

# With positional arguments
fablo init node --set global.fabricVersion=3.0.0 --set orgs[1].peer.instances=5

# Complex nested paths
fablo init --set global.monitoring.loglevel=debug --set channels[0].name=my-channel2

dependabot Bot and others added 6 commits April 17, 2026 05:11
Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.5.0 to 7.5.5.
- [Release notes](https://github.com/protobufjs/protobuf.js/releases)
- [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md)
- [Commits](protobufjs/protobuf.js@protobufjs-v7.5.0...protobufjs-v7.5.5)

---
updated-dependencies:
- dependency-name: protobufjs
  dependency-version: 7.5.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
…mmand

Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
@OsamaRab3

Copy link
Copy Markdown
Contributor

I ran it locally, but it doesn’t work as expected. When running:
./bin/run.mjs init --orgs[0].peer.instances=5
I get the following error:
zsh: no matches found: --orgs[0].peer.instances=5 the same error with ./bin/run.mjs init --channels[0].name=my-channel2 it only work with ./bin/run.mjs init --global.tls=true  Also, I’m not a big fan of the current implementation approach it feels a bit hard to follow and might benefit from simplification or clearer structure.

@HarK-github

HarK-github commented Apr 24, 2026

Copy link
Copy Markdown
Contributor Author

@OsamaRab3 I have made some changes. Try using set flag . ex :/fablo.sh init --set global.fabricVersion=2.5.0 --set global.tls=false

Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
@HarK-github

Copy link
Copy Markdown
Contributor Author

@OsamaRab3 did it work?

@HarK-github

Copy link
Copy Markdown
Contributor Author

@OsamaRab3 can you have a look please

HarK-github and others added 4 commits May 11, 2026 22:54
Comment thread samples/gateway/node/package-lock.json
Comment thread src/commands/init/index.test.ts Outdated
Comment thread src/commands/init/index.ts Outdated
Comment thread src/commands/init/index.ts Outdated
Comment on lines +132 to +134
if (/^-?(0|[1-9]\d*)(\.\d+)?$/.test(trimmed) && trimmed !== "") {
return Number(trimmed);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& trimmed !== "" redundant regex already rejects empty string

Comment thread e2e/fabloCommands.test.ts Outdated
@OsamaRab3

Copy link
Copy Markdown
Contributor

Usage Examples:

# Single override
fablo init --set global.fabricVersion=2.5.0

# Multiple overrides
fablo init --set global.tls=false --set orgs[0].peer.db=CouchDb

# With positional arguments
fablo init node --set global.fabricVersion=3.0.0 --set orgs[1].peer.instances=5

# Complex nested paths
fablo init --set global.monitoring.loglevel=debug --set channels[0].name=my-channel2

Could you update the documentation with a few examples showing how to use --set?

Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
@HarK-github HarK-github requested a review from OsamaRab3 June 26, 2026 10:17
Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
Comment thread e2e/fabloCommands.test.ts
@mergify

mergify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Signed-off-by: Harshit Kandpal <kandpalhar@gmail.com>
@HarK-github HarK-github requested a review from dzikowski June 26, 2026 12:59

@OsamaRab3 OsamaRab3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HarK-github HarK-github changed the title feat(cli): add support for dynamic configuration overrides in init command #444` feat(cli): add support for dynamic configuration overrides in init command #444 Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants