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

feat: fixes the realm URL when it is set. #1545

Merged
merged 2 commits into from
Oct 24, 2023

Conversation

marcosuma
Copy link
Collaborator

Description

When the realm URL is set from our configuration, it was wrongly setting the baseURL without considering the api/admin/v3.0/ part of it. Docs

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

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 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

@marcosuma marcosuma marked this pull request as ready for review October 20, 2023 16:58
@marcosuma marcosuma requested a review from a team as a code owner October 20, 2023 16:58
@@ -100,7 +100,7 @@ func (c *MongoDBClient) GetRealmClient(ctx context.Context) (*realm.Client, erro
optsRealm := []realm.ClientOpt{realm.SetUserAgent(userAgent)}
authConfig := realmAuth.NewConfig(nil)
if c.Config.BaseURL != "" && c.Config.RealmBaseURL != "" {
optsRealm = append(optsRealm, realm.SetBaseURL(c.Config.RealmBaseURL))
optsRealm = append(optsRealm, realm.SetBaseURL(c.Config.RealmBaseURL+"api/admin/v3.0/"))
authConfig.AuthURL, _ = url.Parse(c.Config.RealmBaseURL + "api/admin/v3.0/auth/providers/mongodb-cloud/login")
}

Copy link
Member

Choose a reason for hiding this comment

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

knitpit: to avoid having the same string twice we can do something like:
adminURL := c.Config.RealmBaseURL+"api/admin/v3.0/"
optsRealm = append(optsRealm, realm.SetBaseURL(adminURL))
authConfig.AuthURL, _ = url.Parse(adminURL + "auth/providers/mongodb-cloud/login")

@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Health
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas 2%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/framework/validator 68%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas/util 12%
Summary 3% (271 / 10296)

@marcosuma marcosuma merged commit a7f7217 into master Oct 24, 2023
19 checks passed
@marcosuma marcosuma deleted the INTMDB-1010-fix-realm-base-url branch October 24, 2023 09:34
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.

2 participants