Skip to content

refactor: move domains to package core/{domain}#123

Merged
krtkvrm merged 1 commit intomainfrom
refactor-domain
Jul 25, 2022
Merged

refactor: move domains to package core/{domain}#123
krtkvrm merged 1 commit intomainfrom
refactor-domain

Conversation

@mabdh
Copy link
Member

@mabdh mabdh commented Jul 20, 2022

This is the first PR of some multiple tasks from this issue #121

Ideas
The structure would be layered like this

  • [server(handler)/hook/middleware] > service > repository
  • All components server(handler)/hook/middleware should talk to service layer to process data

Changes

  • move all entities in model to its own domain
  • move schema store interface to its own domain
  • moving the definition vars to its domain package
  • move authz spicedb to store layer
  • move config to its domain SpiceDBConfig to spicedb.Config
  • refactor the cyclic import
    • avoid import cycle user<>group move ListUserGroups in user domain/service to group domain/service, let user be an entity that does not depend on anything
  • permission package has responsibility to all domains, need to separate to its own domain
    • relation package create function, pass a relation struct directly to store layer without picking the component to make the create function reusable
    • move relation functions to to the domain that uses it
  • Refactor CheckPermission to CheckPermission(ctx context.Context, usr user.User, resourceNS namespace.Namespace, resourceIdxa string, action action.Action) (bool, error) to avoid having dependency to resource package.
  • Move CheckAuthz function in permission to ResourceService
  • remove structs package
  • refactor some errors with prefix Err
  • Move integration test to test/integration folder
  • Rename v1.go to v1beta1.go

@mabdh mabdh linked an issue Jul 20, 2022 that may be closed by this pull request
@mabdh mabdh force-pushed the refactor-domain branch from 3fc4f19 to 43a5562 Compare July 20, 2022 07:30
@mabdh mabdh marked this pull request as ready for review July 20, 2022 08:11
@mabdh mabdh marked this pull request as draft July 20, 2022 09:29
@mabdh
Copy link
Member Author

mabdh commented Jul 20, 2022

converting this to draft as we need to test this manually first

@mabdh
Copy link
Member Author

mabdh commented Jul 25, 2022

This PR will also solve #125

@mabdh mabdh force-pushed the refactor-domain branch from abb351c to 01f2e73 Compare July 25, 2022 06:24
@mabdh mabdh force-pushed the refactor-domain branch from 01f2e73 to 0dfcb3a Compare July 25, 2022 06:45
@krtkvrm krtkvrm merged commit a10326c into main Jul 25, 2022
@krtkvrm krtkvrm deleted the refactor-domain branch July 25, 2022 08:56
@ravisuhag ravisuhag linked an issue Jul 26, 2022 that may be closed by this pull request
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.

Shield server not errored out when starting with no connection to spicedb instance ODPF project structure standard

2 participants