-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DBConnector]: Add database config env support #345
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Wataru Ishida <ishida@nel-america.com>
@dzhangalibaba Please also help review |
@@ -27,7 +27,14 @@ void SonicDBConfig::initialize(const string &file) | |||
throw runtime_error("SonicDBConfig already initialized"); | |||
} | |||
|
|||
ifstream i(file); | |||
string filename = file; | |||
if ( filename == "" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( filename == "" ) | |
if (filename.empty()) |
if ( filename == "" ) | ||
{ | ||
const auto env = getenv(SONIC_DB_CONFIG_FILE_ENV_VAL); | ||
filename = env ? string(env) : DEFAULT_SONIC_DB_CONFIG_FILE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string(env) [](start = 25, length = 11)
FYI: no need to explicit convert
if ( filename == "" ) | ||
{ | ||
const auto env = getenv(SONIC_DB_CONFIG_FILE_ENV_VAL); | ||
filename = env ? string(env) : DEFAULT_SONIC_DB_CONFIG_FILE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename = env ? string(env) : DEFAULT_SONIC_DB_CONFIG_FILE; [](start = 8, length = 60)
Add some testcases?
Hi Ishida, when can I expect this to be merged? |
fixes #322