Skip to content

feat:Add config-driven Fabric-X namespaces - #828

Open
MaryamArif7 wants to merge 13 commits into
hyperledger-labs:mainfrom
MaryamArif7:feat_819
Open

MaryamArif7 wants to merge 13 commits into
hyperledger-labs:mainfrom
MaryamArif7:feat_819

Conversation

@MaryamArif7

@MaryamArif7 MaryamArif7 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

fixes #819

This PR adds support for configuring Fabric-X namespaces through the Fablo configuration.

Changes

  1. Added support for defining namespaces in the config.
  2. Added validation for namespace configuration.
  3. Added namespace initialization during network setup.
  4. Supports multiple namespaces.

This makes it easier to set up Fabric-X namespaces without needing to configure them manually.

Changed files

  1. schema.json: added namespaces, next to channels and chaincodes, one shared schema
  2. FabloConfigJson.ts / FabloConfigExtended.ts: added namespace types
  3. defaults.ts: added the org-list-to-policy function
  4. extendConfig.ts: calls namespace resolution for fabric-x only, using only the channel's orgs
  5. validate/index.ts: the fabric-x namespace checks above
  6. init/index.ts: default namespace now uses orgs
  7. base-functions.sh / base-help.sh: generated script and help text reflect config-driven namespaces
  8. fabric-x-docker.sh: passes an optional name through to namespace init
  9. test-08-fabric-x.sh: added targeted init and unknown-name checks to the real Docker e2e test

@MaryamArif7
MaryamArif7 marked this pull request as draft September 9, 2026 10:43
@MaryamArif7

MaryamArif7 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Hi @umegbewe Id like to clarify a few things regarding this PR

  1. The issue requires that Fablo be able to create at least one namespace. Should we enforce this by making namespaces a required field in the config like the network simply cannot be generated without at least one namespace ?

  2. The current plan for namespace init is that it creates every namespace declared in the config, one after another. If a user has multiple namespaces defined, should we also support creating just one specifically where we create nampespace for one ( namespace init ) instead of only being able to create all of them at once?

  3. currenlty every fabric-x-only rule (one channel, no chaincodes, TLS required) is in validate/index.ts, not the schema. So I added namespaces as a plain optional field in the same shared schema, with the "at least one, for fabric-x" rule also enforced in validate/index.t.So here im going with "no separate Fabric-X schema" requirement mentioned in the issue,by just applying that rule only for fabric-x.......

4.Right now we are doing something like this below :Just like this ref Make File

"namespaces": [
  { "name": "mynamespace", "policy": "AND('Org1MSP.member','Org2MSP.member')" }
]

But the flaw with this approach is that

we type the ploicies by hand everytime we add them even tho fablo already knows every org's MSP name from orgs[]

what do you think if we should go with this ?

we can do somethig like this
{ "name": "mynamespace", "orgs": ["Org1", "Org2"] }

with this we can add a helper fun ,resolvePolicy which can input the orgs with namespace names and return this
{ "name": "mynamespace", "policy": "AND('Org1MSP.member','Org2MSP.member')" } it can be flow to the basefunctions

@MaryamArif7
MaryamArif7 marked this pull request as ready for review September 10, 2026 08:35
@MaryamArif7
MaryamArif7 marked this pull request as draft September 15, 2026 04:43
@umegbewe

Copy link
Copy Markdown
Contributor

@MaryamArif7

  1. Do not make namespaces globally required in the JSON schema, because classic Fabric configs should not need it. But yes, for provider == fabric-x validation should require at least one namespace, fablo init fabric-x should generate one by default

  2. namespace init should create all configured namespaces by default. I’d also support namespace init if it is not too much extra work, because once multiple namespaces exist, users will expect targeted creation

  3. Yes, provider-specific rules belong in validate/index.ts, not as global schema requirements. The schema should define the optional top-level namespaces shape. Fabric-X validation should enforce “at least one namespace,” uniqueness, and valid org references.

  4. Yes, use orgs, not hand-written policy as the normal interface. Something like

"namespaces": [
  { "name": "mynamespace", "orgs": ["Org1", "Org2"] }
]

advanced override can be

"namespaces": [
  { "name": "custom", "policy": "AND('Org1MSP.member')" }
]

I’d avoid allowing both orgs and policy in the same namespace for now

@umegbewe
umegbewe marked this pull request as ready for review September 17, 2026 21:13
Comment thread src/extend-config/extendConfig.ts Outdated
Comment thread src/extend-config/defaults.ts
Comment thread src/extend-config/extendConfig.ts Outdated
Comment thread src/commands/validate/index.ts Outdated
Comment thread src/commands/validate/index.ts
Comment thread src/extend-config/extendNamespacesConfig.ts
Comment thread src/types/FabloConfigExtended.ts Outdated
Comment thread src/commands/init/index.ts
@umegbewe

Copy link
Copy Markdown
Contributor

This PR needs tests @MaryamArif7

add tests for:

  • extendNamespacesConfig derives AND('Org1MSP.member','Org2MSP.member') from orgs.
  • policy override is preserved.
  • duplicate namespace names fail.
  • orgs and policy together fails.
  • unknown org fails.
  • empty orgs: [] fails.
  • generated base-functions.sh creates all namespaces by default.
  • namespace init creates only the selected namespace and errors for unknown names.

Good work so far!

@MaryamArif7

MaryamArif7 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@umegbewe
Why the namespace name validation was added

While testing, a namespace named audit-ns failed at runtime. tracing it back to the actual Fabric-X source code showed that namespace IDs are restricted to lowercase letters, digits, and underscores only, no hyphens, with a 60 character limit. That rule lives in fxconfig ,so i have added those validation in valid/index file,extendedconfig and tests files.

Local testing

With the default namespace

Namespace init

image

Namespace list

image

With multiple namespaces added

Namespace init

This initializes every namespace declared in the config file.

image image

Namespace list

This shows all the namespaces that were created.

image

Targeted namespace init

./fablo.sh namespace init audit_ns

image image

Validation checks

image

@MaryamArif7

Copy link
Copy Markdown
Contributor Author

This PR needs tests @MaryamArif7

add tests for:

  • extendNamespacesConfig derives AND('Org1MSP.member','Org2MSP.member') from orgs.
  • policy override is preserved.
  • duplicate namespace names fail.
  • orgs and policy together fails.
  • unknown org fails.
  • empty orgs: [] fails.
  • generated base-functions.sh creates all namespaces by default.
  • namespace init creates only the selected namespace and errors for unknown names.

Good work so far!

hi @umegbewe
All covered in the added test files.
extendNamespacesConfig.test.ts:
covers deriving policy from orgs, policy override, duplicate names, orgs+policy together, empty orgs, and unknown org.

namespaceInit.test.ts
covers the shell side: init creates all namespaces by default, targeted init creates only one, and an unknown name fails cleanly. Also updated test-08-fabric-x.sh with targeted init and unknown name checks.

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.

feat (fabric-x): Add config-driven Fabric-X namespaces

2 participants