PRDONE-94: updated to set dotenv variables as system properties

This commit is contained in:
Tim Chamberlain
2022-08-30 12:28:40 -05:00
parent 4c2ebf8a94
commit dcea96579c
2 changed files with 22 additions and 17 deletions

View File

@ -104,15 +104,16 @@ class ConnectionManagerTest
private RDBMSBackendMetaData getAuroraBacked() private RDBMSBackendMetaData getAuroraBacked()
{ {
Dotenv dotenv = Dotenv.configure() Dotenv dotenv = Dotenv.configure()
.systemProperties()
.ignoreIfMissing() .ignoreIfMissing()
.load(); .load();
return new RDBMSBackendMetaData() return new RDBMSBackendMetaData()
.withName("aurora-test") .withName("aurora-test")
.withVendor(dotenv.get("RDBMS_VENDOR")) .withVendor(System.getProperty("RDBMS_VENDOR"))
.withHostName(dotenv.get("RDBMS_HOSTNAME")) .withHostName(System.getProperty("RDBMS_HOSTNAME"))
.withPort(Integer.valueOf(Objects.requireNonNull(dotenv.get("RDBMS_PORT")))) .withPort(Integer.valueOf(Objects.requireNonNull(System.getProperty("RDBMS_PORT"))))
.withDatabaseName(dotenv.get("RDBMS_DATABASE_NAME")) .withDatabaseName(System.getProperty("RDBMS_DATABASE_NAME"))
.withUsername(dotenv.get("RDBMS_USERNAME")) .withUsername(System.getProperty("RDBMS_USERNAME"))
.withPassword(dotenv.get("RDBMS_PASSWORD")); .withPassword(System.getProperty("RDBMS_PASSWORD"));
} }
} }

View File

@ -137,12 +137,13 @@ public class SampleMetaDataProvider
Dotenv dotenv = Dotenv.configure() Dotenv dotenv = Dotenv.configure()
.ignoreIfMissing() .ignoreIfMissing()
.systemProperties()
.load(); .load();
QWidgetMetaDataInterface quickSightChartMetaData = new QuickSightChartMetaData() QWidgetMetaDataInterface quickSightChartMetaData = new QuickSightChartMetaData()
.withAccountId(dotenv.get("QUICKSIGHT_ACCCOUNT_ID")) .withAccountId(System.getProperty("QUICKSIGHT_ACCCOUNT_ID"))
.withAccessKey(dotenv.get("QUICKSIGHT_ACCESS_KEY")) .withAccessKey(System.getProperty("QUICKSIGHT_ACCESS_KEY"))
.withSecretKey(dotenv.get("QUICKSIGHT_SECRET_KEY")) .withSecretKey(System.getProperty("QUICKSIGHT_SECRET_KEY"))
.withUserArn(dotenv.get("QUICKSIGHT_USER_ARN")) .withUserArn(System.getProperty("QUICKSIGHT_USER_ARN"))
.withDashboardId("9e452e78-8509-4c81-bb7f-967abfc356da") .withDashboardId("9e452e78-8509-4c81-bb7f-967abfc356da")
.withRegion(Regions.US_EAST_2.getName()) .withRegion(Regions.US_EAST_2.getName())
.withName(QuickSightChartRenderer.class.getSimpleName()) .withName(QuickSightChartRenderer.class.getSimpleName())
@ -212,15 +213,18 @@ public class SampleMetaDataProvider
{ {
if(USE_MYSQL) if(USE_MYSQL)
{ {
Dotenv dotenv = Dotenv.configure().load(); Dotenv dotenv = Dotenv.configure()
.ignoreIfMissing()
.systemProperties()
.load();
return new RDBMSBackendMetaData() return new RDBMSBackendMetaData()
.withName(RDBMS_BACKEND_NAME) .withName(RDBMS_BACKEND_NAME)
.withVendor(dotenv.get("RDBMS_VENDOR")) .withVendor(System.getProperty("RDBMS_VENDOR"))
.withHostName(dotenv.get("RDBMS_HOSTNAME")) .withHostName(System.getProperty("RDBMS_HOSTNAME"))
.withPort(Integer.valueOf(Objects.requireNonNull(dotenv.get("RDBMS_PORT")))) .withPort(Integer.valueOf(Objects.requireNonNull(System.getProperty("RDBMS_PORT"))))
.withDatabaseName(dotenv.get("RDBMS_DATABASE_NAME")) .withDatabaseName(System.getProperty("RDBMS_DATABASE_NAME"))
.withUsername(dotenv.get("RDBMS_USERNAME")) .withUsername(System.getProperty("RDBMS_USERNAME"))
.withPassword(dotenv.get("RDBMS_PASSWORD")); .withPassword(System.getProperty("RDBMS_PASSWORD"));
} }
else else
{ {