Skip to content

Commit

Permalink
automate mongo tests (hashicorp#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrannosaurus-becks authored Feb 5, 2020
1 parent 8a0490e commit cdad9bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ jobs:
build:
docker:
- image: circleci/golang:1.13
- image: circleci/mongo:latest
environment:
- MONGO_INITDB_ROOT_USERNAME: root
- MONGO_INITDB_ROOT_PASSWORD: mongodb
- MONGO_INITDB_DATABASE: admin
- image: circleci/mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=mysql
Expand All @@ -24,6 +29,7 @@ jobs:
echo 'GO111MODULE=on' >> $BASH_ENV
echo 'export GOBIN=$GOPATH/bin' >> $BASH_ENV
echo 'export MYSQL_URL="root:mysql@tcp(127.0.0.1:3306)/"' >> $BASH_ENV
echo 'export MONGODB_URL="mongodb://root:mongodb@localhost:27017/admin?ssl=false"' >> $BASH_ENV
- run:
name: "Run Tests"
command: |
Expand Down
34 changes: 6 additions & 28 deletions vault/resource_database_secret_backend_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,10 @@ func databaseSecretBackendConnectionResource() *schema.Resource {
},

"mongodb": {
Type: schema.TypeList,
Optional: true,
Description: "Connection parameters for the mongodb-database-plugin plugin.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"connection_url": {
Type: schema.TypeString,
Optional: true,
Description: "Connection string to use to connect to the database.",
},
},
},
Type: schema.TypeList,
Optional: true,
Description: "Connection parameters for the mongodb-database-plugin plugin.",
Elem: connectionStringResource(),
MaxItems: 1,
ConflictsWith: util.CalculateConflictsWith("mongodb", dbBackendTypes),
},
Expand Down Expand Up @@ -346,9 +338,7 @@ func getDatabaseAPIData(d *schema.ResourceData) (map[string]interface{}, error)
case "hana-database-plugin":
setDatabaseConnectionData(d, "hana.0.", data)
case "mongodb-database-plugin":
if v, ok := d.GetOk("mongodb.0.connection_url"); ok {
data["connection_url"] = v.(string)
}
setDatabaseConnectionData(d, "mongodb.0.", data)
case "mssql-database-plugin":
setDatabaseConnectionData(d, "mssql.0.", data)
case "mysql-database-plugin":
Expand Down Expand Up @@ -559,19 +549,7 @@ func databaseSecretBackendConnectionRead(d *schema.ResourceData, meta interface{
case "hana-database-plugin":
d.Set("hana", getConnectionDetailsFromResponse(d, "hana.0.", resp))
case "mongodb-database-plugin":
details := resp.Data["connection_details"]
data, ok := details.(map[string]interface{})
if ok {
result := map[string]interface{}{}
if v, ok := d.GetOk("mongodb.0." + "connection_url"); ok {
result["connection_url"] = v.(string)
} else {
if v, ok := data["connection_url"]; ok {
result["connection_url"] = v.(string)
}
}
d.Set("mongodb", []map[string]interface{}{result})
}
d.Set("mongodb", getConnectionDetailsFromResponse(d, "mongodb.0.", resp))
case "mssql-database-plugin":
d.Set("mssql", getConnectionDetailsFromResponse(d, "mssql.0.", resp))
case "mysql-database-plugin":
Expand Down

0 comments on commit cdad9bf

Please sign in to comment.