-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created using spr 1.3.4
- Loading branch information
Showing
15 changed files
with
100 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
//! Code that manages command dispatch from a shell for wicket. | ||
use std::net::SocketAddrV6; | ||
|
||
use anyhow::{Context, Result}; | ||
use clap::Parser; | ||
|
||
use super::{ | ||
preflight::PreflightArgs, rack_setup::SetupArgs, upload::UploadArgs, | ||
}; | ||
|
||
pub fn exec( | ||
log: slog::Logger, | ||
args: &str, | ||
wicketd_addr: SocketAddrV6, | ||
) -> Result<()> { | ||
// The argument is in a quoted form, so split it using Unix shell semantics. | ||
let args = shell_words::split(&args).with_context(|| { | ||
format!("could not parse shell arguments from input {args}") | ||
})?; | ||
|
||
// parse_from uses the the first argument as the command name. Insert "wicket" as | ||
// the command name. | ||
let args = ShellCommand::parse_from( | ||
std::iter::once("wicket".to_owned()).chain(args), | ||
); | ||
match args { | ||
ShellCommand::UploadRepo(args) => args.exec(log, wicketd_addr), | ||
ShellCommand::Setup(args) => args.exec(log, wicketd_addr), | ||
ShellCommand::Preflight(args) => args.exec(log, wicketd_addr), | ||
} | ||
} | ||
|
||
/// Arguments passed to wicket. | ||
/// | ||
/// Wicket is designed to be used as a captive shell, set up via sshd | ||
/// ForceCommand. If no arguments are specified, wicket behaves like a TUI. | ||
/// However, if arguments are specified via SSH_ORIGINAL_COMMAND, wicketd | ||
/// accepts an upload command. | ||
#[derive(Debug, Parser)] | ||
enum ShellCommand { | ||
/// Upload a TUF repository to wicketd. | ||
#[command(visible_alias = "upload")] | ||
UploadRepo(UploadArgs), | ||
/// Interact with rack setup configuration. | ||
#[command(subcommand)] | ||
Setup(SetupArgs), | ||
/// Run checks prior to setting up the rack. | ||
#[command(subcommand)] | ||
Preflight(PreflightArgs), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
// Copyright 2023 Oxide Computer Company | ||
|
||
//! Command-line interface to wicket. | ||
//! | ||
//! By default, the main interface to wicket is via a TUI. However, some | ||
//! commands and use cases must be done via the CLI, and this module contains | ||
//! support for that. | ||
mod command; | ||
mod preflight; | ||
mod rack_setup; | ||
mod upload; | ||
|
||
pub use command::exec; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters