Skip to content

Commit 1df3c32

Browse files
committed
provisioning: Start the commands/
For simplicity and plug-n-playability we'll implement each command in its own file, making it quite manageable to add new behaviours and commands in the queue. Signed-off-by: Ikey Doherty <[email protected]>
1 parent 2a5b47f commit 1df3c32

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

crates/provisioning/src/commands.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ use std::sync::Arc;
77
use kdl::KdlNode;
88
use miette::NamedSource;
99

10+
mod create_partition;
11+
mod create_partition_table;
12+
mod find_disk;
13+
1014
/// Command evaluation context
1115
pub(crate) struct Context<'a> {
1216
/// The document being parsed
@@ -19,22 +23,19 @@ pub(crate) struct Context<'a> {
1923
/// A command
2024
#[derive(Debug)]
2125
pub enum Command {
22-
// TODO: Add command variants
23-
Unimplemented,
24-
}
25-
26-
fn dummy_command(_context: Context) -> Result<Command, crate::Error> {
27-
unimplemented!("Command support not implemented");
26+
CreatePartition,
27+
CreatePartitionTable,
28+
FindDisk,
2829
}
2930

3031
/// Command execution function
3132
type CommandExec = for<'a> fn(Context<'a>) -> Result<Command, crate::Error>;
3233

3334
/// Map of command names to functions
3435
static COMMANDS: phf::Map<&'static str, CommandExec> = phf::phf_map! {
35-
"find-disk" => dummy_command,
36-
"create-partition" => dummy_command,
37-
"create-partition-table" => dummy_command,
36+
"find-disk" => find_disk::parse,
37+
"create-partition" => create_partition::parse,
38+
"create-partition-table" => create_partition_table::parse,
3839
};
3940

4041
/// Parse a command from a node if possible
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-FileCopyrightText: Copyright © 2025 Serpent OS Developers
2+
//
3+
// SPDX-License-Identifier: MPL-2.0
4+
5+
use super::{Command, Context};
6+
7+
/// Generate a command to create a partition
8+
pub(crate) fn parse(_context: Context<'_>) -> Result<Command, crate::Error> {
9+
unimplemented!("Command not implemented");
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-FileCopyrightText: Copyright © 2025 Serpent OS Developers
2+
//
3+
// SPDX-License-Identifier: MPL-2.0
4+
5+
use super::{Command, Context};
6+
7+
/// Generate a command to create a partition table
8+
pub(crate) fn parse(_context: Context<'_>) -> Result<Command, crate::Error> {
9+
unimplemented!("Command not implemented");
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-FileCopyrightText: Copyright © 2025 Serpent OS Developers
2+
//
3+
// SPDX-License-Identifier: MPL-2.0
4+
5+
use super::{Command, Context};
6+
7+
/// Generate a command to find a disk
8+
pub(crate) fn parse(_context: Context<'_>) -> Result<Command, crate::Error> {
9+
unimplemented!("Command not implemented");
10+
}

0 commit comments

Comments
 (0)