-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathpartitions.rs
More file actions
55 lines (47 loc) · 1.72 KB
/
Copy pathpartitions.rs
File metadata and controls
55 lines (47 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use trident_api::storage_graph::containers::AllowBlockList;
use crate::markdown::table::MdTable;
use super::{get_part_types, RuleDefinition};
pub(super) fn valid_mount_paths() -> RuleDefinition {
let mut table = MdTable::new(vec!["Partition Type", "Valid Mount Paths"]);
for pt in get_part_types() {
table.add_row(vec![
pt.to_string(),
match pt.valid_mountpoints() {
AllowBlockList::None => "None".to_owned(),
AllowBlockList::Any => "Any path".to_owned(),
AllowBlockList::Allow(paths) => paths
.iter()
.map(|p| format!("`{}`", p.display()))
.collect::<Vec<String>>()
.join(" or "),
AllowBlockList::Block(paths) => format!(
"Any except: {}",
paths
.iter()
.map(|p| format!("`{}`", p.display()))
.collect::<Vec<String>>()
.join(" nor ")
),
},
]);
}
RuleDefinition {
name: "Partition Type Valid Mounting Paths",
template: "valid_mount_paths",
body: table.render(),
}
}
pub(super) fn matching_hash_partition() -> RuleDefinition {
let mut table = MdTable::new(vec!["Partition Type", "Matching Hash Partition"]);
for (pt, ptv) in get_part_types()
.iter()
.filter_map(|pt| pt.to_verity().map(|ptv| (pt, ptv)))
{
table.add_row(vec![pt.to_string(), ptv.to_string()]);
}
RuleDefinition {
name: "Partition Type Matching Hash Partition",
template: "matching_hash_partition",
body: table.render(),
}
}