Skip to content

Commit 7b495d7

Browse files
committed
provisioning: Implement find-disk constraints
Signed-off-by: Ikey Doherty <[email protected]>
1 parent 74b2980 commit 7b495d7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

crates/provisioning/src/commands/find_disk.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
use itertools::Itertools;
66

7-
use crate::Context;
7+
use crate::{Constraints, Context};
88

99
#[derive(Debug)]
1010
pub struct Command {
1111
pub name: String,
12+
pub constraints: Option<Constraints>,
1213
}
1314

1415
/// Generate a command to find a disk
@@ -41,5 +42,15 @@ pub(crate) fn parse(context: Context<'_>) -> Result<super::Command, crate::Error
4142
}
4243
};
4344

44-
Ok(super::Command::FindDisk(Box::new(Command { name: name.to_owned() })))
45+
let constraints =
46+
if let Some(constraints) = context.node.iter_children().find(|n| n.name().value() == "constraints") {
47+
Some(Constraints::from_kdl_node(constraints)?)
48+
} else {
49+
None
50+
};
51+
52+
Ok(super::Command::FindDisk(Box::new(Command {
53+
name: name.to_owned(),
54+
constraints,
55+
})))
4556
}

crates/provisioning/tests/use_whole_disk.kdl

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ strategy name="whole_disk" summary="Wipe and use an entire disk" {
44
// The result is stored in "root_disk" (disk=..)
55
find-disk "root_disk" {
66
constraints {
7-
min (GB)"30"
8-
//- partition-table "gpt" // Require gpt for reuse
7+
min (GB)30
98
}
109
}
1110

0 commit comments

Comments
 (0)