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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mongodbatlas/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ 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))
authConfig.AuthURL, _ = url.Parse(c.Config.RealmBaseURL + "api/admin/v3.0/auth/providers/mongodb-cloud/login")
adminURL := c.Config.RealmBaseURL + "api/admin/v3.0/"
optsRealm = append(optsRealm, realm.SetBaseURL(adminURL))
authConfig.AuthURL, _ = url.Parse(adminURL + "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")

token, err := authConfig.NewTokenFromCredentials(ctx, c.Config.PublicKey, c.Config.PrivateKey)
Expand Down
Loading