Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

API: Implement import managed resource #329

Merged
nxtcoder17 merged 2 commits into
mainfrom
feat/import-mres
May 31, 2024
Merged

API: Implement import managed resource #329
nxtcoder17 merged 2 commits into
mainfrom
feat/import-mres

Conversation

@nxtcoder19
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new field.

Adding a comment for the new ClusterName field would improve code readability and maintainability.

Suggested change
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new field.

Adding a comment for the new IsImported field would improve code readability and maintainability.

Suggested change
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new field.

Adding a comment for the new ManagedServiceName field would improve code readability and maintainability.

Suggested change
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new field.

Adding a comment for the new MresRef field would improve code readability and maintainability.

Suggested change
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new function.

Adding a comment for the new CoreGetImportedManagedResource function would improve code readability and maintainability.

Suggested change
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) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new function.

Adding a comment for the new ListImportedManagedResources function would improve code readability and maintainability.

Suggested change
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) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new function.

Adding a comment for the new listImportedMres function would improve code readability and maintainability.

Suggested change
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,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new field.

Adding a comment for the new AccountName field would improve code readability and maintainability.

Suggested change
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,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding a comment for the new field.

Adding a comment for the new ManagedResourceMresRef field would improve code readability and maintainability.

Suggested change
fc.ManagedResourceMresRef: mresName,
// ManagedResourceMresRef is used to filter resources based on the managed resource reference name.
fc.ManagedResourceMresRef: mresName,

return nil
}

type GetClusterManagedServiceIn struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"`
}

- refactor managed resource to create inside managed service
- implement import managed resource inside environment
@nxtcoder17 nxtcoder17 merged commit 5100de1 into main May 31, 2024
@nxtcoder17 nxtcoder17 deleted the feat/import-mres branch May 31, 2024 05:14
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
API: Implement import managed resource
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API: Implement import managed resource

2 participants