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

refactor: adjust project_api_key to new file structure #1676

Merged
merged 2 commits into from
Nov 29, 2023

Conversation

AgustinBettati
Copy link
Member

Description

Link to any related issue(s): INTMDB-1387

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

@AgustinBettati AgustinBettati requested a review from a team as a code owner November 28, 2023 17:15
@@ -108,8 +109,8 @@ func getDataSourcesMap() map[string]*schema.Resource {
"mongodbatlas_api_keys": mongodbatlas.DataSourceAPIKeys(),
"mongodbatlas_access_list_api_key": mongodbatlas.DataSourceAccessListAPIKey(),
"mongodbatlas_access_list_api_keys": mongodbatlas.DataSourceAccessListAPIKeys(),
"mongodbatlas_project_api_key": mongodbatlas.DataSourceProjectAPIKey(),
"mongodbatlas_project_api_keys": mongodbatlas.DataSourceProjectAPIKeys(),
"mongodbatlas_project_api_key": projectapikey.DataSourceProjectAPIKey(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit-non-blocking] given the decision on one package per resource and to follow the "don't stutter" general recommendation of go

Suggested change
"mongodbatlas_project_api_key": projectapikey.DataSourceProjectAPIKey(),
"mongodbatlas_project_api_key": projectapikey.DataSource(),

Copy link
Member Author

Choose a reason for hiding this comment

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

this makes sense, will do a followup PR to adjust all of the resources that have already been adjusted to new structure.

Copy link
Member

Choose a reason for hiding this comment

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

nice, thx

@@ -42,7 +43,7 @@ func dataSourceMongoDBAtlasOrgIDRead(ctx context.Context, d *schema.ResourceData
for idx, role := range apiKeyOrgList.APIKey.Roles {
if strings.HasPrefix(role.RoleName, "ORG_") {
if err := d.Set("org_id", apiKeyOrgList.APIKey.Roles[idx].OrgID); err != nil {
return diag.Errorf(ErrorProjectSetting, `org_id`, root.APIKey.ID, err)
return diag.Errorf(projectapikey.ErrorProjectSetting, `org_id`, root.APIKey.ID, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this error seems to be defined in the wrong package

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah this message was not accurate, adjusted and left a new constant to help with consistency in error messages

Copy link
Contributor

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 0%
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 3% (315 / 10714)

@lantoli
Copy link
Member

lantoli commented Nov 29, 2023

the failing test is the flaky test so feel free to merge even if that failing test

@AgustinBettati AgustinBettati merged commit d71180f into master Nov 29, 2023
27 of 28 checks passed
@AgustinBettati AgustinBettati deleted the INTMDB-1387 branch November 29, 2023 10:39
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

3 participants