|
1 | 1 | use crate::{ |
2 | 2 | blocks::{Block, BlockBehavior, FromDocument}, |
3 | 3 | client::LocalValueProvider, |
4 | | - context::{BlockContext, ContextResolver, DocumentSshConfig, DocumentSshHost, SshIdentityKeyConfig}, |
| 4 | + context::{ |
| 5 | + BlockContext, ContextResolver, DocumentSshConfig, DocumentSshHost, SshIdentityKeyConfig, |
| 6 | + }, |
5 | 7 | }; |
6 | 8 | use async_trait::async_trait; |
7 | 9 | use serde::{Deserialize, Serialize}; |
@@ -69,9 +71,7 @@ impl FromDocument for SshConnect { |
69 | 71 | Some(v) => match v.as_u64() { |
70 | 72 | Some(0) => None, // 0 means "not set" |
71 | 73 | Some(p) if p <= 65535 => Some(p as u16), |
72 | | - Some(p) => { |
73 | | - return Err(format!("Invalid SSH port: {} (must be 1-65535)", p).into()) |
74 | | - } |
| 74 | + Some(p) => return Err(format!("Invalid SSH port: {} (must be 1-65535)", p).into()), |
75 | 75 | None => return Err("Invalid SSH port: expected a number".into()), |
76 | 76 | }, |
77 | 77 | None => None, |
@@ -102,14 +102,18 @@ impl SshConnect { |
102 | 102 | if key_value.is_empty() { |
103 | 103 | None |
104 | 104 | } else { |
105 | | - Some(SshIdentityKeyConfig::Paste { content: key_value.to_string() }) |
| 105 | + Some(SshIdentityKeyConfig::Paste { |
| 106 | + content: key_value.to_string(), |
| 107 | + }) |
106 | 108 | } |
107 | 109 | } |
108 | 110 | "path" => { |
109 | 111 | if key_value.is_empty() { |
110 | 112 | None |
111 | 113 | } else { |
112 | | - Some(SshIdentityKeyConfig::Path { path: key_value.to_string() }) |
| 114 | + Some(SshIdentityKeyConfig::Path { |
| 115 | + path: key_value.to_string(), |
| 116 | + }) |
113 | 117 | } |
114 | 118 | } |
115 | 119 | _ => None, |
@@ -241,11 +245,7 @@ impl BlockBehavior for SshConnect { |
241 | 245 | let identity_key = if let Some(provider) = block_local_value_provider { |
242 | 246 | match provider.get_block_local_value(self.id, "identityKey").await { |
243 | 247 | Ok(Some(value)) => { |
244 | | - tracing::debug!( |
245 | | - "Block {} read identityKey from KV: {}", |
246 | | - self.id, |
247 | | - value |
248 | | - ); |
| 248 | + tracing::debug!("Block {} read identityKey from KV: {}", self.id, value); |
249 | 249 | Self::parse_identity_key_from_local(&value) |
250 | 250 | } |
251 | 251 | Ok(None) => { |
@@ -642,7 +642,8 @@ mod tests { |
642 | 642 | assert!(result.is_none()); |
643 | 643 |
|
644 | 644 | // Unknown mode |
645 | | - let result = SshConnect::parse_identity_key_from_local(r#"{"mode": "unknown", "value": "test"}"#); |
| 645 | + let result = |
| 646 | + SshConnect::parse_identity_key_from_local(r#"{"mode": "unknown", "value": "test"}"#); |
646 | 647 | assert!(result.is_none()); |
647 | 648 | } |
648 | 649 |
|
|
0 commit comments