Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ kdl = "6.3.3"
log = "0.4.21"
miette = "7.5.0"
nix = { version = "0.30.1", features = ["fs", "mount"] }
phf = "0.11"
serde = { version = "1.0" }
serde_json = "1.0"
snafu = "0.8.5"
Expand Down
1 change: 0 additions & 1 deletion crates/provisioning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ types = { path = "../types", features = ["kdl"] }
kdl = { workspace = true, features = ["span"] }
miette = { workspace = true }
itertools = { workspace = true }
phf = { workspace = true, features = ["macros"] }
test-log.workspace = true
log.workspace = true
16 changes: 9 additions & 7 deletions crates/provisioning/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ pub enum Command {
/// Command execution function
type CommandExec = for<'a> fn(Context<'a>) -> Result<Command, crate::Error>;

/// Map of command names to functions
static COMMANDS: phf::Map<&'static str, CommandExec> = phf::phf_map! {
"find-disk" => find_disk::parse,
"create-partition" => create_partition::parse,
"create-partition-table" => create_partition_table::parse,
};
fn command(name: &str) -> Option<CommandExec> {
Some(match name {
"find-disk" => find_disk::parse,
"create-partition" => create_partition::parse,
"create-partition-table" => create_partition_table::parse,
_ => return None,
})
}

/// Parse a command from a node if possible
pub(crate) fn parse_command(context: Context<'_>) -> Result<Command, crate::Error> {
let name = context.node.name().value();
let func = COMMANDS.get(name).ok_or_else(|| crate::UnsupportedNode {
let func = command(name).ok_or_else(|| crate::UnsupportedNode {
at: context.node.span(),
name: name.into(),
})?;
Expand Down