|
8 | 8 |
|
9 | 9 | use std::path::PathBuf; |
10 | 10 |
|
| 11 | +use const_format::concatcp; |
11 | 12 | use kms::{plugins::kbs::KbcClient, Annotations, Getter}; |
12 | 13 | use log::debug; |
13 | 14 | use tokio::fs; |
14 | 15 |
|
15 | | -use crate::{hub::Hub, Error, Result}; |
| 16 | +use crate::{hub::Hub, hub::CDH_BASE_DIR, Error, Result}; |
16 | 17 |
|
17 | | -/// This directory is used to store all the kbs resources get by CDH's init |
18 | | -/// function, s.t. `[[Credential]]` sections in the config.toml file. |
19 | | -pub const KBS_RESOURCE_STORAGE_DIR: &str = "/run/confidential-containers/cdh"; |
| 18 | +/// Directory for KBS resources (credentials, etc.) fetched at init, see the `[[credentials]]` |
| 19 | +/// sections in CDH's `config.toml` file, for an example, see `example.config.toml`. |
| 20 | +const KBS_RESOURCE_STORAGE_DIR: &str = concatcp!(CDH_BASE_DIR, "/kbs"); |
20 | 21 |
|
21 | 22 | impl Hub { |
22 | 23 | pub(crate) async fn init_kbs_resources(&self) -> Result<()> { |
@@ -86,11 +87,11 @@ fn is_path_valid(path: &str) -> bool { |
86 | 87 | mod tests { |
87 | 88 | use rstest::rstest; |
88 | 89 |
|
89 | | - use crate::auth::kbs::{is_path_valid, KBS_RESOURCE_STORAGE_DIR}; |
| 90 | + use super::{is_path_valid, KBS_RESOURCE_STORAGE_DIR}; |
90 | 91 |
|
91 | 92 | #[rstest] |
92 | 93 | #[case("/etc/config.toml".into(), false)] |
93 | | - #[case(format!("{KBS_RESOURCE_STORAGE_DIR}/../../config.toml"), false)] |
| 94 | + #[case(format!("{KBS_RESOURCE_STORAGE_DIR}/../../config.toml",), false)] |
94 | 95 | #[case(format!("{KBS_RESOURCE_STORAGE_DIR}/kms-credential/../../../config.toml"), false)] |
95 | 96 | #[case(format!("{KBS_RESOURCE_STORAGE_DIR}/kms-credential/./config.toml"), false)] |
96 | 97 | #[case(format!("{KBS_RESOURCE_STORAGE_DIR}/kms-credential/aliyun/config.toml"), true)] |
|
0 commit comments