Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sbchaos
Copy link
Contributor

@sbchaos sbchaos commented Sep 25, 2022

No description provided.

@coveralls
Copy link

coveralls commented Sep 25, 2022

Pull Request Test Coverage Report for Build 3214991025

  • 561 of 567 (98.94%) changed or added relevant lines in 12 files are covered.
  • 100 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+2.5%) to 80.239%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core/tenant/service/secret_service.go 71 77 92.21%
Files with Coverage Reduction New Missed Lines %
api/handler/v1beta1/error_helper.go 4 33.33%
job/dependency_resolver.go 15 94.72%
api/handler/v1beta1/adapter.go 18 73.18%
job/service.go 63 84.97%
Totals Coverage Status
Change from base Build 3133499995: 2.5%
Covered Lines: 8324
Relevant Lines: 10374

💛 - Coveralls

@sbchaos sbchaos linked an issue Sep 27, 2022 that may be closed by this pull request
5 tasks
@sbchaos sbchaos marked this pull request as ready for review September 29, 2022 04:20
}
}

func NewTenant(projectName string, namespaceName string) (Tenant, error) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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() == "" {
Copy link
Contributor

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
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@sbchaos sbchaos merged commit 5600250 into main Oct 10, 2022
@sbchaos sbchaos deleted the feature/tenant_bounded_context branch October 10, 2022 08:47
deryrahman pushed a commit that referenced this pull request Oct 17, 2022
* 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]>
@sbchaos sbchaos linked an issue Jan 3, 2023 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.

Introduce tenant bounded context Secrets should be consumed through service, and not through project

4 participants