Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit d0f5fda

Browse files
authored
Support creating v3.6 mongoDB account (#732)
* Support creating v3.6 mongoDB * Add e2e test * fix: lint
1 parent 42e6f1e commit d0f5fda

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed

docs/modules/cosmosdb.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Provisions a new CosmosDB database account that can be accessed through the Mong
218218
|----------------|------|-------------|----------|---------------|
219219
| `location` | `string` | The Azure region in which to provision applicable resources. | Y | |
220220
| `resourceGroup` | `string` | The (new or existing) resource group with which to associate new resources. | Y | |
221+
| `version` | `string` | The version of MongoDB api. Allowed values are: ["3.2", "3.6"] | Y | If not specified, 3.2 will be used. |
221222
| `tags` | `map[string]string` | Tags to be applied to new resources, specified as key/value pairs. | N | Tags (even if none are specified) are automatically supplemented with `heritage: open-service-broker-azure`. |
222223
| `ipFilters` | `object` | IP Range Filter to be applied to new CosmosDB account | N | A default filter is created that allows only Azure service access |
223224
| `ipFilters.allowAccessFromAzure` | `string` | Specifies if Azure Services should be able to access the CosmosDB account. Valid valued are `""` (unspecified), `enabled`, or `disabled`. | N | If left unspecified, defaults to enabled. |

pkg/services/cosmosdb/catalog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ func (m *module) GetCatalog() (service.Catalog, error) {
154154
},
155155
Schemas: service.PlanSchemas{
156156
ServiceInstances: service.InstanceSchemas{
157-
ProvisioningParametersSchema: generateProvisioningParamsSchema(), // nolint: lll
158-
UpdatingParametersSchema: generateUpdatingParamsSchema(), // nolint: lll
157+
ProvisioningParametersSchema: generateMongoDBProvisionParamsSchema(), // nolint: lll
158+
UpdatingParametersSchema: generateUpdatingParamsSchema(), // nolint: lll
159159
},
160160
},
161161
}),

pkg/services/cosmosdb/mongodb-provision.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ func (m *mongoAccountManager) deployARMTemplate(
3434
if err != nil {
3535
return nil, err
3636
}
37+
38+
mongoDBVersion := pp.GetString("version")
39+
if mongoDBVersion == mongoDBVersion36 {
40+
p["capability"] = "EnableMongo"
41+
}
3742
tags := getTags(pp)
3843
fqdn, pk, err := m.cosmosAccountManager.deployARMTemplate(
3944
pp,

pkg/services/cosmosdb/mongodb-types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ func (
2626
func (m *mongoAccountManager) GetEmptyBindingDetails() service.BindingDetails {
2727
return nil
2828
}
29+
30+
const (
31+
mongoDBVersion36 = "3.6"
32+
mongoDBVersion32 = "3.2"
33+
)

pkg/services/cosmosdb/plan_schemas.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ func generateProvisioningParamsSchema() service.InputParametersSchema {
153153
}
154154
}
155155

156+
func generateMongoDBProvisionParamsSchema() service.InputParametersSchema {
157+
sharedProvisioningSchema := generateProvisioningParamsSchema()
158+
sharedProvisioningSchema.PropertySchemas["version"] = &service.StringPropertySchema{ // nolint: lll
159+
Title: "The version of MongoDB api",
160+
Description: "Specifies the version you want to use " +
161+
"in created MongoDB acccount.",
162+
AllowedValues: []string{mongoDBVersion32, mongoDBVersion36},
163+
DefaultValue: mongoDBVersion32,
164+
}
165+
return sharedProvisioningSchema
166+
}
167+
156168
func ipRangeValidator(context, value string) error {
157169
ip := net.ParseIP(value)
158170
if ip == nil {

tests/lifecycle/cosmosdb_cases_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,25 @@ var cosmosdbTestCases = []serviceLifecycleTestCase{
109109
"readRegions": []interface{}{},
110110
},
111111
},
112+
{ // MongoDB v3.6
113+
group: "cosmosdb",
114+
name: "mongo-api-account-only-v3.6",
115+
serviceID: "8797a079-5346-4e84-8018-b7d5ea5c0e3a",
116+
planID: "86fdda05-78d7-4026-a443-1325928e7b02",
117+
118+
testCredentials: testMongoDBCreds,
119+
provisioningParameters: map[string]interface{}{
120+
"location": "eastus",
121+
"version": "3.6",
122+
"ipFilters": map[string]interface{}{
123+
"allowedIPRanges": []interface{}{"0.0.0.0/0"},
124+
},
125+
"consistencyPolicy": map[string]interface{}{
126+
"defaultConsistencyLevel": "Session",
127+
},
128+
"readRegions": []interface{}{"westus"},
129+
},
130+
},
112131
{ // SQL API All In One
113132
group: "cosmosdb",
114133
name: "sql-api-all-in-one",

0 commit comments

Comments
 (0)