(path: &Path)
| 46 | } |
| 47 | |
| 48 | fn read_cluster_secret(path: &Path) -> Result<[u8; CLUSTER_SECRET_LEN], String> { |
| 49 | let bytes = |
| 50 | fs::read(path).map_err(|e| format!("read cluster secret {}: {e}", path.display()))?; |
| 51 | if bytes.len() != CLUSTER_SECRET_LEN { |
| 52 | return Err(format!( |
| 53 | "cluster secret {} has {} bytes, expected {CLUSTER_SECRET_LEN}", |
| 54 | path.display(), |
| 55 | bytes.len() |
| 56 | )); |
| 57 | } |
| 58 | let mut out = [0u8; CLUSTER_SECRET_LEN]; |
| 59 | out.copy_from_slice(&bytes); |
| 60 | Ok(out) |
| 61 | } |
| 62 | |
| 63 | #[cfg(test)] |
| 64 | mod tests { |