Skip to content
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

chore: project resource migration to new sdk #1686

Merged
merged 19 commits into from
Dec 1, 2023
Merged

chore: project resource migration to new sdk #1686

merged 19 commits into from
Dec 1, 2023

Conversation

oarbusi
Copy link
Collaborator

@oarbusi oarbusi commented Nov 30, 2023

Description

Migrate project resource to new SDK

Link to any related issue(s): https://jira.mongodb.org/browse/CLOUDP-213827

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

@oarbusi oarbusi marked this pull request as ready for review November 30, 2023 16:48
@oarbusi oarbusi requested a review from a team as a code owner November 30, 2023 16:48
Comment on lines -150 to -153
options := &matlas.ListOptions{
PageNum: int(stateModel.PageNum.ValueInt64()),
ItemsPerPage: int(stateModel.ItemsPerPage.ValueInt64()),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason to ignore pagination now?

Copy link
Collaborator Author

@oarbusi oarbusi Dec 1, 2023

Choose a reason for hiding this comment

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

With new SDK, ListProjects uses default values for pagination instead of the values from stateModel. Fixed it so I don't change the behaviour. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

the old SDK should've had defaults as well, reason to ask is I have no context where stateModel was and if those values where meaningful

results := make([]*tfProjectDSModel, 0, len(projectsRes.Results))
for _, project := range projectsRes.Results {
atlasTeams, atlasLimits, atlasProjectSettings, err := getProjectPropsFromAPI(ctx, conn, connV2, project.ID)
for i, project := range projectsRes.Results {
Copy link
Member

Choose a reason for hiding this comment

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

i think it's better not to mix index and object in the loop, so in this case I recommend:
for i := range projectsRes.Results {
project := &projectsRes.Results[i]
...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have a strong opinion on this, but I am curious about why we should not mix object and index?

Copy link
Member

@lantoli lantoli left a comment

Choose a reason for hiding this comment

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

good overall, minor comments

Copy link
Contributor

github-actions bot commented Dec 1, 2023

Code Coverage

Package Line Rate Health
github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion 31%
github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate 68%
github.com/mongodb/terraform-provider-mongodbatlas/internal/provider 5%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster 3%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/alertconfiguration 33%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/atlasuser 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cluster 1%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/databaseuser 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrest 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/project 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectapikey 1%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectipaccesslist 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/searchdeployment 23%
github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc 5%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas 2%
Summary 4% (434 / 10694)

@oarbusi oarbusi merged commit e910b23 into master Dec 1, 2023
28 checks passed
@oarbusi oarbusi deleted the CLOUDP-213827 branch December 1, 2023 11:33
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.

None yet

4 participants