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

Commit

Permalink
Support creating v3.6 mongoDB account (#732)
Browse files Browse the repository at this point in the history
* Support creating v3.6 mongoDB

* Add e2e test

* fix: lint
  • Loading branch information
norshtein authored Dec 17, 2019
1 parent 42e6f1e commit d0f5fda
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/modules/cosmosdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Provisions a new CosmosDB database account that can be accessed through the Mong
|----------------|------|-------------|----------|---------------|
| `location` | `string` | The Azure region in which to provision applicable resources. | Y | |
| `resourceGroup` | `string` | The (new or existing) resource group with which to associate new resources. | Y | |
| `version` | `string` | The version of MongoDB api. Allowed values are: ["3.2", "3.6"] | Y | If not specified, 3.2 will be used. |
| `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`. |
| `ipFilters` | `object` | IP Range Filter to be applied to new CosmosDB account | N | A default filter is created that allows only Azure service access |
| `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. |
Expand Down
4 changes: 2 additions & 2 deletions pkg/services/cosmosdb/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ func (m *module) GetCatalog() (service.Catalog, error) {
},
Schemas: service.PlanSchemas{
ServiceInstances: service.InstanceSchemas{
ProvisioningParametersSchema: generateProvisioningParamsSchema(), // nolint: lll
UpdatingParametersSchema: generateUpdatingParamsSchema(), // nolint: lll
ProvisioningParametersSchema: generateMongoDBProvisionParamsSchema(), // nolint: lll
UpdatingParametersSchema: generateUpdatingParamsSchema(), // nolint: lll
},
},
}),
Expand Down
5 changes: 5 additions & 0 deletions pkg/services/cosmosdb/mongodb-provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func (m *mongoAccountManager) deployARMTemplate(
if err != nil {
return nil, err
}

mongoDBVersion := pp.GetString("version")
if mongoDBVersion == mongoDBVersion36 {
p["capability"] = "EnableMongo"
}
tags := getTags(pp)
fqdn, pk, err := m.cosmosAccountManager.deployARMTemplate(
pp,
Expand Down
5 changes: 5 additions & 0 deletions pkg/services/cosmosdb/mongodb-types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ func (
func (m *mongoAccountManager) GetEmptyBindingDetails() service.BindingDetails {
return nil
}

const (
mongoDBVersion36 = "3.6"
mongoDBVersion32 = "3.2"
)
12 changes: 12 additions & 0 deletions pkg/services/cosmosdb/plan_schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ func generateProvisioningParamsSchema() service.InputParametersSchema {
}
}

func generateMongoDBProvisionParamsSchema() service.InputParametersSchema {
sharedProvisioningSchema := generateProvisioningParamsSchema()
sharedProvisioningSchema.PropertySchemas["version"] = &service.StringPropertySchema{ // nolint: lll
Title: "The version of MongoDB api",
Description: "Specifies the version you want to use " +
"in created MongoDB acccount.",
AllowedValues: []string{mongoDBVersion32, mongoDBVersion36},
DefaultValue: mongoDBVersion32,
}
return sharedProvisioningSchema
}

func ipRangeValidator(context, value string) error {
ip := net.ParseIP(value)
if ip == nil {
Expand Down
19 changes: 19 additions & 0 deletions tests/lifecycle/cosmosdb_cases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ var cosmosdbTestCases = []serviceLifecycleTestCase{
"readRegions": []interface{}{},
},
},
{ // MongoDB v3.6
group: "cosmosdb",
name: "mongo-api-account-only-v3.6",
serviceID: "8797a079-5346-4e84-8018-b7d5ea5c0e3a",
planID: "86fdda05-78d7-4026-a443-1325928e7b02",

testCredentials: testMongoDBCreds,
provisioningParameters: map[string]interface{}{
"location": "eastus",
"version": "3.6",
"ipFilters": map[string]interface{}{
"allowedIPRanges": []interface{}{"0.0.0.0/0"},
},
"consistencyPolicy": map[string]interface{}{
"defaultConsistencyLevel": "Session",
},
"readRegions": []interface{}{"westus"},
},
},
{ // SQL API All In One
group: "cosmosdb",
name: "sql-api-all-in-one",
Expand Down

0 comments on commit d0f5fda

Please sign in to comment.