mirror of
https://codeberg.org/spire/dispenser.git
synced 2026-06-04 02:24:07 +02:00
clippy
This commit is contained in:
parent
76ba9682a5
commit
38f3b96e35
5 changed files with 38 additions and 18 deletions
|
|
@ -125,7 +125,7 @@ impl Vultr {
|
|||
.applications
|
||||
.into_iter()
|
||||
.find_map(|application| {
|
||||
(application.short_name == short_name).then(|| application.image_id)
|
||||
(application.short_name == short_name).then_some(application.image_id)
|
||||
})
|
||||
.ok_or_else(|| {
|
||||
ResponseError::Other(format!("Application \"{}\" not found", short_name))
|
||||
|
|
|
|||
|
|
@ -73,9 +73,7 @@ where
|
|||
D: Deserializer<'de>,
|
||||
{
|
||||
let raw = <Option<String>>::deserialize(deserializer)?;
|
||||
raw.map(load_secret)
|
||||
.transpose()
|
||||
.map_err(|e| D::Error::custom(e))
|
||||
raw.map(load_secret).transpose().map_err(D::Error::custom)
|
||||
}
|
||||
|
||||
fn deserialize_secret<'de, D>(deserializer: D) -> Result<String, D::Error>
|
||||
|
|
@ -83,12 +81,12 @@ where
|
|||
D: Deserializer<'de>,
|
||||
{
|
||||
let raw = String::deserialize(deserializer)?;
|
||||
load_secret(raw).map_err(|e| D::Error::custom(e))
|
||||
load_secret(raw).map_err(D::Error::custom)
|
||||
}
|
||||
|
||||
fn load_secret(raw: String) -> Result<String, std::io::Error> {
|
||||
let path: &Path = raw.as_ref();
|
||||
if raw.starts_with("/") && path.exists() {
|
||||
if raw.starts_with('/') && path.exists() {
|
||||
let raw = read_to_string(raw)?;
|
||||
Ok(raw.trim().into())
|
||||
} else {
|
||||
|
|
|
|||
17
src/main.rs
17
src/main.rs
|
|
@ -35,7 +35,7 @@ struct Args {
|
|||
config: String,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
#[derive(Subcommand, Default)]
|
||||
enum Commands {
|
||||
/// Start a new server if none is running
|
||||
Start,
|
||||
|
|
@ -44,15 +44,10 @@ enum Commands {
|
|||
/// List running servers
|
||||
List,
|
||||
/// Run the management daemon
|
||||
#[default]
|
||||
Daemon,
|
||||
}
|
||||
|
||||
impl Default for Commands {
|
||||
fn default() -> Self {
|
||||
Commands::Daemon
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error("Error while interacting with cloud provider: {0}")]
|
||||
|
|
@ -360,9 +355,9 @@ async fn start(cloud: &dyn Cloud, config: &Config) -> Result<Server, Error> {
|
|||
|
||||
async fn set_dyndns(dns_config: DynDnsConfig, ip: IpAddr) {
|
||||
let dns = DynDnsClient::new(
|
||||
dns_config.update_url.to_string(),
|
||||
dns_config.username.to_string(),
|
||||
dns_config.password.to_string(),
|
||||
dns_config.update_url,
|
||||
dns_config.username,
|
||||
dns_config.password,
|
||||
);
|
||||
println!(
|
||||
"Updating DynDNS entry for {} to {}",
|
||||
|
|
@ -380,7 +375,7 @@ async fn connect_ssh(ip: IpAddr, auth: &CreatedAuth) -> Result<SshSession, Error
|
|||
tries += 1;
|
||||
sleep(Duration::from_secs(5)).await;
|
||||
|
||||
match SshSession::open(ip, &auth).await {
|
||||
match SshSession::open(ip, auth).await {
|
||||
Ok(ssh) => {
|
||||
return Ok(ssh);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue