-
Notifications
You must be signed in to change notification settings - Fork 154
refactor: add tenant bounded context #619
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
Conversation
Co-authored-by: Sandeep Bhardwaj <[email protected]>
Pull Request Test Coverage Report for Build 3214991025
💛 - Coveralls |
| } | ||
| } | ||
|
|
||
| func NewTenant(projectName string, namespaceName string) (Tenant, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we split this into NewProjectScopedTenant && NewNamespaceScopedTenant, it will be explicit & we don't need to ignore the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will still require the constructor with optional namespace, otherwise the caller will have to make the decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also adding a new Constructor for namespace mandatory tenant as NewNamespaceTenant
| } | ||
|
|
||
| func (t TenantService) GetDetails(ctx context.Context, tnnt tenant.Tenant) (*tenant.WithDetails, error) { | ||
| if tnnt.ProjectName() == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is n't needed as tenant won't be created without projectname
| return nil, err | ||
| } | ||
|
|
||
| var namespace *tenant.Namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets see if we can avoid this complexity of tenant optional behaviour by keeping things explicit
| return tenant.NewSecret(s.Name, typ, string(encrypted), t) | ||
| } | ||
|
|
||
| func (s Secret) ToSecretInfo() (*dto.SecretInfo, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to do this in service layer, where repository will always return secrets stored in DB in that case creation of PlainTextSecret & SecretInfo is the responsibility of service layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Secret does not have some of the fields required, we will require a dto to send those values to service.
* refactor: add support for project in tenant bounded context Co-authored-by: Sandeep Bhardwaj <[email protected]> * feat: add test for project handler, service and store * refactor: add test for project and improve errors * refactor: add validation in project * refactor: improve mock to get rid of nil reference error * refactor: use sql for CRUD in project repo * feat: add service, model and handler for namespace * refactor: add namespace repository * feat: add app_key and tenant models * refactor: add secret models * wip: add handler for secrets * refactor: add secret handler and service * refactor: add secret repository * fix: fix lint errors * fix: move new repository test to repository test command * refactor: add tenant service * fix: fix lint error * refactor: wire tenant handlers in optimus server * refactor: remove unused handlers * refactor: move query to usage * refactor: remove unused code * refactor: fix as per feedback comments * fix: fix unit test * refactor: use secrets as pointer and not value type * refactor: add mandatory namespace constructor * refactor: do not expose mocks Co-authored-by: Sravan Korumilli <[email protected]>
No description provided.