From d153b2ccc0135dd0484181d997cbeaf0c19f7d15 Mon Sep 17 00:00:00 2001 From: Stefan Martinov Date: Tue, 7 Nov 2017 14:47:25 +0100 Subject: [PATCH] Get mongodb optionaly from env variables --- configuration/configuration.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/configuration/configuration.go b/configuration/configuration.go index d4bc95d..ae3fed9 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -1,13 +1,15 @@ package configuration +import "os" + var ( MONGO_DB string = "shop" MONGO_DB_PRODUCTS string = "products" - LocalUnitTests = "dockerhost/" + MONGO_DB + LocalUnitTests = "localhost/" + MONGO_DB WithDocker = "mongo/" + MONGO_DB - ProductsLocal = "dockerhost/" + MONGO_DB_PRODUCTS + ProductsLocal = "localhost/" + MONGO_DB_PRODUCTS ProductsDocker = "mongo/" + MONGO_DB_PRODUCTS // MONGO_BASE_URL = "mongodb://dockerhost/" @@ -31,3 +33,10 @@ var ( // AllowedLanguages contains language codes for all allowed languages var AllowedLanguages = [...]string{"de", "fr"} + +func GetMongoURL() string { + if url, exists := os.LookupEnv("MONGO_URL"); exists { + return url + } + return MONGO_URL +}