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

fix: Avoids import error for database_user when both username and auth database contain hyphens #2928

Merged
merged 6 commits into from
Dec 31, 2024

Conversation

EspenAlbert
Copy link
Collaborator

@EspenAlbert EspenAlbert commented Dec 26, 2024

Description

  • Avoids import error for database_user when both username and auth database contain hyphens
  • Adds ImportSplit3 helper function for splitting id by /. See details on why / in issue

Link to any related issue(s): CLOUDP-289266 #2876

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. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • 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 have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@github-actions github-actions bot added the bug label Dec 26, 2024
@EspenAlbert EspenAlbert marked this pull request as ready for review December 26, 2024 10:38
@EspenAlbert EspenAlbert requested review from a team as code owners December 26, 2024 10:38
Copy link
Contributor

APIx bot: a message has been sent to Docs Slack channel

Copy link

@erabil-mdb erabil-mdb left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +13 to +20
func ImportSplit3(importRaw string) (ok bool, part1, part2, part3 string) {
parts := strings.Split(importRaw, "/")
if len(parts) != 3 {
return false, "", "", ""
}
return true, parts[0], parts[1], parts[2]
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

[Curious] Is the use of / as a separator for import applied to all the resources? Besides this question, I think you should add additional documentation to highlight this change in the TF doc

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 would update the resource documentation import section.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Updated in c866b36
So far, this is only used by this resource. Added a ticket here to discuss more usages

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice. Left a small comment on the import doc but this is good for me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This decision does indeed bring a good conversation to have if it should be extended to all resources


```
$ terraform import mongodbatlas_database_user.my_user 1112222b3bf99403840e8934-my_user-admin
terraform import mongodbatlas_database_user.my_user 1112222b3bf99403840e8934-my_user-admin # (1)
terraform import mongodbatlas_database_user.my_user 1112222b3bf99403840e8934/my-username-dash/my-db-name # (2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we include here when user needs to use one format vs. the other?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point to explain why and when

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated in caef9ba

@EspenAlbert EspenAlbert merged commit 728c536 into master Dec 31, 2024
40 checks passed
@EspenAlbert EspenAlbert deleted the CLOUDP-289266_database_user_import branch December 31, 2024 07:51
svc-apix-Bot added a commit that referenced this pull request Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants