Skip to content

Commit eabc6b9

Browse files
committed
support custom API base URL
depends on akshaykarle/go-mongodbatlas#20
1 parent 27ab4b7 commit eabc6b9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

mongodbatlas/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import (
1010
type Config struct {
1111
AtlasUsername string
1212
AtlasAPIKey string
13+
AtlasAPIURL string
1314
}
1415

1516
func (c *Config) NewClient() *ma.Client {
1617
t := dac.NewTransport(c.AtlasUsername, c.AtlasAPIKey)
1718
httpClient := &http.Client{Transport: &t}
18-
client := ma.NewClient(httpClient)
19+
client := ma.NewCustomURLClient(httpClient, c.AtlasAPIURL)
1920
return client
2021
}

mongodbatlas/provider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func Provider() terraform.ResourceProvider {
2020
DefaultFunc: schema.EnvDefaultFunc("MONGODB_ATLAS_API_KEY", ""),
2121
Description: "MongoDB Atlas API Key",
2222
},
23+
"api_url": {
24+
Type: schema.TypeString,
25+
Optional: true,
26+
DefaultFunc: schema.EnvDefaultFunc("MONGODB_ATLAS_API_URL", "https://cloud.mongodb.com/api/atlas/v1.0/"),
27+
Description: "MongoDB Atlas API base url",
28+
},
2329
},
2430

2531
DataSourcesMap: map[string]*schema.Resource{
@@ -45,6 +51,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
4551
config := Config{
4652
AtlasUsername: d.Get("username").(string),
4753
AtlasAPIKey: d.Get("api_key").(string),
54+
AtlasAPIURL: d.Get("api_url").(string),
4855
}
4956

5057
client := config.NewClient()

0 commit comments

Comments
 (0)