chore: reformat & clippy cleanup (#96)
Clippy is now added to the `check` in the pipeline Co-authored-by: Ian Letourneau <letourneau.ian@gmail.com> Reviewed-on: #96
This commit is contained in:
@@ -6,7 +6,7 @@ readme.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.123", features = [ "derive" ] }
|
||||
serde = { version = "1.0.123", features = ["derive"] }
|
||||
log = { workspace = true }
|
||||
env_logger = { workspace = true }
|
||||
russh = { workspace = true }
|
||||
@@ -18,8 +18,11 @@ opnsense-config-xml = { path = "../opnsense-config-xml" }
|
||||
chrono = "0.4.38"
|
||||
russh-sftp = "2.0.6"
|
||||
serde_json = "1.0.133"
|
||||
tokio-util = { version = "0.7.13", features = [ "codec" ] }
|
||||
tokio-util = { version = "0.7.13", features = ["codec"] }
|
||||
tokio-stream = "0.1.17"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions.workspace = true
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(e2e_test)'] }
|
||||
|
||||
@@ -210,7 +210,7 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_load_config_from_local_file() {
|
||||
for path in vec![
|
||||
for path in [
|
||||
"src/tests/data/config-opnsense-25.1.xml",
|
||||
"src/tests/data/config-vm-test.xml",
|
||||
"src/tests/data/config-structure.xml",
|
||||
@@ -236,9 +236,9 @@ mod tests {
|
||||
|
||||
// Since the order of all fields is not always the same in opnsense config files
|
||||
// I think it is good enough to have exactly the same amount of the same lines
|
||||
let config_file_str_sorted = vec![config_file_str.lines().collect::<Vec<_>>()].sort();
|
||||
let serialized_sorted = vec![config_file_str.lines().collect::<Vec<_>>()].sort();
|
||||
assert_eq!(config_file_str_sorted, serialized_sorted);
|
||||
[config_file_str.lines().collect::<Vec<_>>()].sort();
|
||||
[config_file_str.lines().collect::<Vec<_>>()].sort();
|
||||
assert_eq!((), ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ mod tests {
|
||||
///
|
||||
/// * `true` if the package name is found in the CSV string, `false` otherwise.
|
||||
fn is_package_in_csv(csv_string: &str, package_name: &str) -> bool {
|
||||
package_name.len() > 0 && csv_string.split(',').any(|pkg| pkg.trim() == package_name)
|
||||
!package_name.is_empty() && csv_string.split(',').any(|pkg| pkg.trim() == package_name)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -45,7 +45,7 @@ impl SshConfigManager {
|
||||
async fn reload_all_services(&self) -> Result<String, Error> {
|
||||
info!("Reloading all opnsense services");
|
||||
self.opnsense_shell
|
||||
.exec(&format!("configctl service reload all"))
|
||||
.exec("configctl service reload all")
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#[allow(clippy::module_inception)]
|
||||
mod config;
|
||||
mod manager;
|
||||
mod shell;
|
||||
|
||||
@@ -107,7 +107,7 @@ impl OPNsenseShell for SshOPNSenseShell {
|
||||
match result {
|
||||
Ok(bytes) => {
|
||||
if !bytes.is_empty() {
|
||||
remote_file.write(&bytes).await?;
|
||||
AsyncWriteExt::write_all(&mut remote_file, &bytes).await?;
|
||||
}
|
||||
}
|
||||
Err(e) => todo!("Error unhandled {e}"),
|
||||
@@ -194,9 +194,9 @@ async fn wait_for_completion(channel: &mut Channel<Msg>) -> Result<String, Error
|
||||
)));
|
||||
}
|
||||
}
|
||||
russh::ChannelMsg::Success { .. }
|
||||
russh::ChannelMsg::Success
|
||||
| russh::ChannelMsg::WindowAdjusted { .. }
|
||||
| russh::ChannelMsg::Eof { .. } => {}
|
||||
| russh::ChannelMsg::Eof => {}
|
||||
_ => {
|
||||
return Err(Error::Unexpected(format!(
|
||||
"Russh got unexpected msg {msg:?}"
|
||||
|
||||
@@ -64,7 +64,7 @@ impl<'a> DhcpConfig<'a> {
|
||||
.dhcpd
|
||||
.elements
|
||||
.iter_mut()
|
||||
.find(|(name, _config)| return name == "lan")
|
||||
.find(|(name, _config)| name == "lan")
|
||||
.expect("Interface lan should have dhcpd activated")
|
||||
.1
|
||||
}
|
||||
@@ -93,11 +93,7 @@ impl<'a> DhcpConfig<'a> {
|
||||
== ipaddr
|
||||
&& m.mac == mac
|
||||
}) {
|
||||
info!(
|
||||
"Mapping already exists for {} [{}], skipping",
|
||||
ipaddr.to_string(),
|
||||
mac
|
||||
);
|
||||
info!("Mapping already exists for {} [{}], skipping", ipaddr, mac);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -145,9 +141,8 @@ impl<'a> DhcpConfig<'a> {
|
||||
.exec("configctl dhcpd list static")
|
||||
.await?;
|
||||
|
||||
let value: serde_json::Value = serde_json::from_str(&list_static_output).expect(&format!(
|
||||
"Got invalid json from configctl {list_static_output}"
|
||||
));
|
||||
let value: serde_json::Value = serde_json::from_str(&list_static_output)
|
||||
.unwrap_or_else(|_| panic!("Got invalid json from configctl {list_static_output}"));
|
||||
let static_maps = value["dhcpd"]
|
||||
.as_array()
|
||||
.ok_or(Error::Command(format!(
|
||||
|
||||
Reference in New Issue
Block a user