Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouping layers #1034

Closed
anton-kotik opened this issue Nov 23, 2022 · 2 comments
Closed

Grouping layers #1034

anton-kotik opened this issue Nov 23, 2022 · 2 comments

Comments

@anton-kotik
Copy link

anton-kotik commented Nov 23, 2022

For projects with huge number of layers, it would be useful to allow group layers. Something like this:

deptrac:
  layers:
    - {name: AAA, collectors: ...}
    - {name: ABB, collectors: ...}
    - {name: CBB, collectors: ...}
    - {name: BBB, collectors: ...}
    - {name: XAX, collectors: ...}
    - {name: CCX, collectors: ...}
  groups:
    GroupA: [AAA, ABB, XAX]
    GroupB: [ABB, CBB, BBB]
    GroupC: [CBB, CXX]
    GroupX: [XAX, CCX]
    GroupAB: [GroupA, GroupB]
    GroupCX: [GroupC, GroupX]
    GroupAX: [GroupA, GroupX]
  ruleset:
    CBB: [GroupAX]         # CBB can use AAA, ABB, XAX, CCX
    GroupA: [GroupAB, CCX] # [AAA, ABB, XAX] can use AAA, XAX, ABB, CBB, BBB, CXX
    GroupX: [GroupA, BBB]  # [XAX, CCX] can use AAA, ABB, XAX, BBB

Notes:

  • Any layer can be included in several groups. For example, layer CBB is included into GroupB, GroupC, GroupAB, GroupCX groups.
  • Ruleset for groups should be merged. For example, XAX can use all allowed dependencies from both rules GroupA: [GroupAB, CCX] and GroupX: [GroupA, BBB], because XAX is included into both GroupA and GroupX.

Real example, one of many actually: we have dozens separated APIs. Each concrete API is a separate layer, so dependencies between them are forbidden. And we have common dependencies we would like to allow for all these API layers, now we have to write a massive ruleset:

deptrac:
  layers:
    - {name: Api1, collectors: ...}
    - {name: Api2, collectors: ...}
    - {name: Api3, collectors: ...}
    - ...
    - {name: Common1, collectors: ...}
    - {name: Common2, collectors: ...}
    - {name: Common3, collectors: ...}
    - ...
  ruleset:
    Api1: [Common1, Common2, Common2, ...]
    Api2: [Common1, Common2, Common2, ...]
    Api3: [Common1, Common2, Common2, ...]
    ...

More clear version could be:

deptrac:
  layers:
    - {name: Api1, collectors: ...}
    - {name: Api2, collectors: ...}
    - {name: Api3, collectors: ...}
    - ...
    - {name: Common1, collectors: ...}
    - {name: Common2, collectors: ...}
    - {name: Common3, collectors: ...}
    - ...
  groups:
    API: [Api1, Api2, Api3, ...]
    Common: [Common1, Common2, Common3...]
  ruleset:
    API: [CommonGroup]
@patrickkusebauch
Copy link
Collaborator

This could be done fairly easily once #1002 is merged.

@patrickkusebauch
Copy link
Collaborator

Closing as #1002 is now merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants