Skip to content

Commit 6f07b6e

Browse files
committed
Rename CONFIG_PATHS to CONFIG_FILES for more clarity
1 parent b99a712 commit 6f07b6e

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

fact/src/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod reloader;
1515
#[cfg(test)]
1616
mod tests;
1717

18-
const CONFIG_PATHS: [&str; 4] = [
18+
const CONFIG_FILES: [&str; 4] = [
1919
"/etc/stackrox/fact.yml",
2020
"/etc/stackrox/fact.yaml",
2121
"fact.yml",
@@ -42,7 +42,7 @@ impl FactConfig {
4242
}
4343

4444
fn build() -> anyhow::Result<FactConfig> {
45-
let mut config = CONFIG_PATHS
45+
let mut config = CONFIG_FILES
4646
.iter()
4747
.filter_map(|p| {
4848
let p = Path::new(p);

fact/src/config/reloader.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tokio::{
99
time::interval,
1010
};
1111

12-
use super::{EndpointConfig, FactConfig, CONFIG_PATHS};
12+
use super::{EndpointConfig, FactConfig, CONFIG_FILES};
1313

1414
pub struct Reloader {
1515
config: FactConfig,
@@ -73,34 +73,34 @@ impl Reloader {
7373
fn update_cache(&mut self) -> bool {
7474
let mut res = false;
7575

76-
for path in CONFIG_PATHS {
77-
let p = PathBuf::from(path);
78-
if p.exists() {
79-
let mtime = match p.metadata() {
76+
for file in CONFIG_FILES {
77+
let path = PathBuf::from(file);
78+
if path.exists() {
79+
let mtime = match path.metadata() {
8080
Ok(m) => m.mtime(),
8181
Err(e) => {
82-
warn!("Failed to stat {path}: {e}");
82+
warn!("Failed to stat {file}: {e}");
8383
warn!("Configuration reloading may not work");
8484
continue;
8585
}
8686
};
87-
match self.files.get_mut(&path) {
87+
match self.files.get_mut(&file) {
8888
Some(old) if *old == mtime => {}
8989
Some(old) => {
90-
debug!("Updating '{path}'");
90+
debug!("Updating '{file}'");
9191
res = true;
9292
*old = mtime;
9393
}
9494
None => {
95-
debug!("New configuration file '{path}'");
95+
debug!("New configuration file '{file}'");
9696
res = true;
97-
self.files.insert(path, mtime);
97+
self.files.insert(file, mtime);
9898
}
9999
}
100-
} else if self.files.contains_key(&path) {
101-
debug!("'{path}' no longer exists, removing from cache");
100+
} else if self.files.contains_key(&file) {
101+
debug!("'{file}' no longer exists, removing from cache");
102102
res = true;
103-
self.files.remove(&path);
103+
self.files.remove(&file);
104104
}
105105
}
106106
res
@@ -142,7 +142,7 @@ impl Reloader {
142142

143143
impl From<FactConfig> for Reloader {
144144
fn from(config: FactConfig) -> Self {
145-
let files = CONFIG_PATHS
145+
let files = CONFIG_FILES
146146
.iter()
147147
.filter_map(|path| {
148148
let p = PathBuf::from(path);

0 commit comments

Comments
 (0)