Fix Mongo initialization to use environment variables for db/coll names (#1331)

* Updated mongo init to use db name env variable.

* Updated mongo init to use coll name env var.

* Fixed merge conflict.

* Updated formatting in mongo_test.
This commit is contained in:
Bob Maertz
2019-08-15 04:41:21 +00:00
committed by Manu Gupta
parent ba9dc5470e
commit 994810324e
5 changed files with 70 additions and 13 deletions
+12 -6
View File
@@ -169,9 +169,10 @@ func TestStorageEnvOverrides(t *testing.T) {
Region: "us-west-1",
},
Mongo: &MongoConfig{
URL: "mongoURL",
CertPath: "/test/path",
DefaultDBName: "athens",
URL: "mongoURL",
CertPath: "/test/path",
DefaultDBName: "test",
DefaultCollectionName: "testModules",
},
S3: &S3Config{
Region: "s3Region",
@@ -239,9 +240,11 @@ func TestParseExampleConfig(t *testing.T) {
Bucket: "gomods",
},
Mongo: &MongoConfig{
URL: "mongodb://127.0.0.1:27017",
CertPath: "",
InsecureConn: false,
URL: "mongodb://127.0.0.1:27017",
CertPath: "",
InsecureConn: false,
DefaultDBName: "athens",
DefaultCollectionName: "modules",
},
S3: &S3Config{
Region: "MY_AWS_REGION",
@@ -341,6 +344,9 @@ func getEnvMap(config *Config) map[string]string {
envVars["ATHENS_MONGO_STORAGE_URL"] = storage.Mongo.URL
envVars["ATHENS_MONGO_CERT_PATH"] = storage.Mongo.CertPath
envVars["ATHENS_MONGO_INSECURE"] = strconv.FormatBool(storage.Mongo.InsecureConn)
envVars["ATHENS_MONGO_DEFAULT_DATABASE"] = storage.Mongo.DefaultDBName
envVars["ATHENS_MONGO_DEFAULT_COLLECTION"] = storage.Mongo.DefaultCollectionName
}
if storage.S3 != nil {
envVars["AWS_REGION"] = storage.S3.Region