-
Notifications
You must be signed in to change notification settings - Fork 748
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
Suppress user and password info output via Config structure. #947
Conversation
Thanks for the contribution! Please review the labels and make any necessary changes. |
self.clickhouse_handler_thread_num, self.flight_api_address, self.http_api_address, self.metric_api_address, | ||
self.store_api_address, self.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.
maybe should add new line : )
#[derive(Clone, Debug, serde::Deserialize, PartialEq, StructOpt, StructOptToml)] | ||
impl fmt::Debug for Config{ | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{{ log_level: \"{}\", log_dir: \"{}\", num_cpus: {}, mysql_handler_host: \"{}\", |
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.
It looks like a JSON. maybe we can consider the following two implementations:
- Reference https://github.com/rust-lang/rust/blob/master/library/core/src/fmt/mod.rs#L523 to implemented.
or
- Use serde::Serialize and skip field attribute
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.
I will follow up. Thx.
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.
Or we can implement the following code and change the type of store_api_password to Password
struct Password {
plain_text : String
}
impl Debug for Password {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "******");
}
}
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.
.
Please review and give more precious advice. |
We need implement to_string() function to work with env_helper! macro. |
|
||
#[structopt(long, short = "c", env = CONFIG_FILE, default_value = "")] | ||
pub config_file: String, | ||
} | ||
#[derive(Clone, serde::Deserialize, PartialEq, StructOpt, StructOptToml)] |
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.
need new line.
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.
ok
write!(f, "******") | ||
} | ||
} | ||
#[derive(Clone, serde::Deserialize, PartialEq, StructOpt, StructOptToml)] |
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.
need new line
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.
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.
We use rust-fmt to format the code. You can use make lint
to check the format
Hello @wangzhen11aaa, 🎉 Thank you for opening the pull request! 🎉 |
Need to implement ToString trait for User and Password. |
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.
LGTM
Thank you @wangzhen11aaa
CI Passed |
I hereby agree to the terms of the CLA available at: https://datafuse.rs/policies/cla/
Summary
Draft pull request. May not the best solution, Please give advice about the improvement.
Changelog
Rewrite the Debug trait for the Config structure. This fix will affect the extension of the Config, and seems not the best answer.
Improvement
Not for changelog (changelog entry is not required)
Related Issues
fixes #935
Test Plan
Unit Tests
Stateless Tests