Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ishidawataru
Copy link

fixes #322

Signed-off-by: Wataru Ishida <ishida@nel-america.com>
@lguohan lguohan requested a review from qiluo-msft June 10, 2020 19:20
@qiluo-msft
Copy link
Contributor

@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 == "" )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Contributor

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;
Copy link
Contributor

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?

@vasant17
Copy link
Contributor

vasant17 commented Sep 22, 2020

Hi Ishida, when can I expect this to be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make database config optional
3 participants