API: Implement import managed resource #329
Conversation
There was a problem hiding this comment.
Hey @nxtcoder19 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 14 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
| ManagedResource struct { | ||
| APIVersion func(childComplexity int) int | ||
| AccountName func(childComplexity int) int | ||
| ClusterName func(childComplexity int) int |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new field.
Adding a comment for the new ClusterName field would improve code readability and maintainability.
| ClusterName func(childComplexity int) int | |
| // ClusterName represents the name of the cluster associated with the managed resource. | |
| ClusterName func(childComplexity int) int |
| Enabled func(childComplexity int) int | ||
| EnvironmentName func(childComplexity int) int | ||
| Id func(childComplexity int) int | ||
| IsImported func(childComplexity int) int |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new field.
Adding a comment for the new IsImported field would improve code readability and maintainability.
| IsImported func(childComplexity int) int | |
| // IsImported indicates whether the item is imported. | |
| IsImported func(childComplexity int) int |
| IsImported func(childComplexity int) int | ||
| Kind func(childComplexity int) int | ||
| LastUpdatedBy func(childComplexity int) int | ||
| ManagedServiceName func(childComplexity int) int |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new field.
Adding a comment for the new ManagedServiceName field would improve code readability and maintainability.
| ManagedServiceName func(childComplexity int) int | |
| // ManagedServiceName represents the complexity function for the ManagedServiceName field. | |
| ManagedServiceName func(childComplexity int) int |
| LastUpdatedBy func(childComplexity int) int | ||
| ManagedServiceName func(childComplexity int) int | ||
| MarkedForDeletion func(childComplexity int) int | ||
| MresRef func(childComplexity int) int |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new field.
Adding a comment for the new MresRef field would improve code readability and maintainability.
| MresRef func(childComplexity int) int | |
| // MresRef is a function that calculates the complexity of the MresRef field. | |
| MresRef func(childComplexity int) int |
| CoreGetManagedResouceOutputKeyValues func(childComplexity int, envName string, keyrefs []*domain.ManagedResourceKeyRef) int | ||
| CoreGetManagedResouceOutputKeys func(childComplexity int, envName string, name string) int | ||
| CoreGetManagedResource func(childComplexity int, envName string, name string) int | ||
| CoreGetImportedManagedResource func(childComplexity int, envName string, name string) int |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new function.
Adding a comment for the new CoreGetImportedManagedResource function would improve code readability and maintainability.
| CoreGetImportedManagedResource func(childComplexity int, envName string, name string) int | |
| // CoreGetImportedManagedResource calculates the complexity for fetching an imported managed resource. | |
| // It takes into account the child complexity, environment name, and resource name. | |
| CoreGetImportedManagedResource func(childComplexity int, envName string, name string) int |
| return d.mresRepo.FindPaginated(ctx, d.mresRepo.MergeMatchFilters(filters, search), pq) | ||
| } | ||
|
|
||
| func (d *domain) ListImportedManagedResources(ctx ResourceContext, search map[string]repos.MatchFilter, pq repos.CursorPagination) (*repos.PaginatedRecord[*entities.ManagedResource], error) { |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new function.
Adding a comment for the new ListImportedManagedResources function would improve code readability and maintainability.
| func (d *domain) ListImportedManagedResources(ctx ResourceContext, search map[string]repos.MatchFilter, pq repos.CursorPagination) (*repos.PaginatedRecord[*entities.ManagedResource], error) { | |
| func (d *domain) ListImportedManagedResources(ctx ResourceContext, search map[string]repos.MatchFilter, pq repos.CursorPagination) (*repos.PaginatedRecord[*entities.ManagedResource], error) { | |
| // ListImportedManagedResources retrieves a paginated list of managed resources | |
| // based on the provided search filters and pagination parameters. | |
| // It ensures the user has read permissions in the specified environment. |
| } | ||
|
|
||
| func (d *domain) findMRes(ctx ResourceContext, name string) (*entities.ManagedResource, error) { | ||
| func (d *domain) listImportedMres(ctx ConsoleContext, mresName string) ([]*entities.ManagedResource, error) { |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new function.
Adding a comment for the new listImportedMres function would improve code readability and maintainability.
| func (d *domain) listImportedMres(ctx ConsoleContext, mresName string) ([]*entities.ManagedResource, error) { | |
| func (d *domain) listImportedMres(ctx ConsoleContext, mresName string) ([]*entities.ManagedResource, error) { | |
| // listImportedMres retrieves a list of imported Managed Resources based on the provided name. | |
| // It returns a slice of pointers to ManagedResource entities and an error if any occurs during the process. |
| func (d *domain) listImportedMres(ctx ConsoleContext, mresName string) ([]*entities.ManagedResource, error) { | ||
|
|
||
| filter := repos.Filter{ | ||
| fields.AccountName: ctx.AccountName, |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new field.
Adding a comment for the new AccountName field would improve code readability and maintainability.
| fields.AccountName: ctx.AccountName, | |
| // AccountName is used to filter resources by the account associated with the context | |
| fields.AccountName: ctx.AccountName, |
|
|
||
| filter := repos.Filter{ | ||
| fields.AccountName: ctx.AccountName, | ||
| fc.ManagedResourceMresRef: mresName, |
There was a problem hiding this comment.
suggestion: Consider adding a comment for the new field.
Adding a comment for the new ManagedResourceMresRef field would improve code readability and maintainability.
| fc.ManagedResourceMresRef: mresName, | |
| // ManagedResourceMresRef is used to filter resources based on the managed resource reference name. | |
| fc.ManagedResourceMresRef: mresName, |
| return nil | ||
| } | ||
|
|
||
| type GetClusterManagedServiceIn struct { |
There was a problem hiding this comment.
suggestion: Consider adding validation for new struct fields
Adding validation for fields like UserId, UserName, UserEmail, AccountName, and MsvcName can help ensure data integrity and prevent potential issues.
| type GetClusterManagedServiceIn struct { | |
| type GetClusterManagedServiceIn struct { | |
| state protoimpl.MessageState | |
| sizeCache protoimpl.SizeCache | |
| UserId string `validate:"required"` | |
| UserName string `validate:"required"` | |
| UserEmail string `validate:"required,email"` | |
| AccountName string `validate:"required"` | |
| MsvcName string `validate:"required"` | |
| } |
1a225b0 to
faacc55
Compare
- refactor managed resource to create inside managed service - implement import managed resource inside environment
faacc55 to
a593f7a
Compare
API: Implement import managed resource
Resolves kloudlite/kloudlite#224