Skip to content

Commit 95c995b

Browse files
committed
feat: get password from toml config
1 parent f75cf82 commit 95c995b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

uplink/src/collector/clickhouse_collector.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::base::clock;
1212
pub struct ClickhouseCollectorConfig {
1313
pub url: String,
1414
pub username: String,
15-
pub password: String,
1615
}
1716

1817
#[derive(Clone)]
@@ -23,10 +22,20 @@ pub struct ClickhouseCollector {
2322

2423
impl ClickhouseCollector {
2524
pub fn new(config: &ClickhouseCollectorConfig, data_tx: Sender<Payload>) -> Self {
25+
26+
let password = std::fs::read_to_string("/home/ubuntu/compose.yaml")
27+
.expect("couldn't read compose.yaml")
28+
.lines()
29+
.find(|line| line.contains("CLICKHOUSE_PASSWORD"))
30+
.expect("couldn't find CLICKHOUSE_PASSWORD in compose.yaml")
31+
.trim()
32+
.get(21..)
33+
.expect("invalid CLICKHOUSE_PASSWORD")
34+
.to_owned();
2635
let client = clickhouse::Client::default()
2736
.with_url(&config.url)
2837
.with_user(&config.username)
29-
.with_password(&config.password);
38+
.with_password(password);
3039

3140
Self { client, data_tx }
3241
}

0 commit comments

Comments
 (0)