Skip to content

Commit

Permalink
CLEO -> Introduce opendut-cleo create uuid command for randomly gen…
Browse files Browse the repository at this point in the history
…erating a UUID.

This is useful in the `opendut-cleo apply` command.
  • Loading branch information
mbfm committed Dec 19, 2024
1 parent 16d19cf commit 69eae4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions doc/src/user-manual/cleo/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ spec:

```

The `id` fields contain UUIDs. You can generate a random UUID when newly creating a resource with the `opendut-cleo create uuid` command.


## Generating PeerSetup Strings

To create a PeerSetup, it is necessary to provide the PeerID of the peer:
Expand Down
16 changes: 13 additions & 3 deletions opendut-cleo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::process::ExitCode;
use clap::{CommandFactory, Parser, Subcommand, ValueEnum};
use clap_complete::Shell;
use console::Style;

use uuid::Uuid;
use opendut_carl_api::carl::{CaCertInfo, CarlClient};
use opendut_types::topology::{DeviceId, DeviceName};
use opendut_util::settings::{load_config, FileFormat, LoadedConfig};
Expand Down Expand Up @@ -123,7 +123,9 @@ enum CreateResource {
Peer(commands::peer::create::CreatePeerCli),
ContainerExecutor(commands::executor::create::CreateContainerExecutorCli),
NetworkInterface(commands::network_interface::create::CreateNetworkInterfaceCli),
Device(commands::device::create::CreateDeviceCli)
Device(commands::device::create::CreateDeviceCli),
/// Generate a random UUID, which can be used for assigning a new ID to a resource
Uuid,
}

#[derive(Subcommand)]
Expand Down Expand Up @@ -244,26 +246,34 @@ async fn execute_command(commands: Commands, settings: &LoadedConfig) -> Result<
implementation.execute(&mut carl).await?;
}
Commands::Create { resource, output } => {
let mut carl = create_carl_client(&settings.config).await;
match *resource {
CreateResource::ClusterConfiguration(implementation) => {
let mut carl = create_carl_client(&settings.config).await;
implementation.execute(&mut carl, output).await?;
}
CreateResource::ClusterDeployment(implementation) => {
let mut carl = create_carl_client(&settings.config).await;
implementation.execute(&mut carl, output).await?;
}
CreateResource::Peer(implementation) => {
let mut carl = create_carl_client(&settings.config).await;
implementation.execute(&mut carl, output).await?;
}
CreateResource::ContainerExecutor(implementation) => {
let mut carl = create_carl_client(&settings.config).await;
implementation.execute(&mut carl, output).await?;
}
CreateResource::NetworkInterface(implementation) => {
let mut carl = create_carl_client(&settings.config).await;
implementation.execute(&mut carl, output).await?;
}
CreateResource::Device(implementation) => {
let mut carl = create_carl_client(&settings.config).await;
implementation.execute(&mut carl, output).await?;
}
CreateResource::Uuid => {
println!("{}", Uuid::new_v4());
}
}
}
Commands::GenerateSetupString(implementation) => {
Expand Down

0 comments on commit 69eae4e

Please sign in to comment.