Skip to content

Commit

Permalink
fix all clippy errors and update versions (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragnyll committed Jan 27, 2022
1 parent ad45736 commit 4cad8e7
Show file tree
Hide file tree
Showing 37 changed files with 96 additions and 87 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/check-rust.yml
Expand Up @@ -46,6 +46,8 @@ jobs:
run: cargo fmt --all -- --check
- name: Check clippy
run: cargo clippy --all
- name: Check clippy for tests
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run check
run: cargo check
- name: Check for H2 patch not being applied
Expand All @@ -57,4 +59,4 @@ jobs:
- name: Run tests --ignored
run: cargo test -- --ignored
- name: Run doc
run: cargo doc --no-deps
run: export RUSTDOCFLAGS="-Dwarnings" && cargo doc --no-deps
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "agent"
version = "0.8.1"
version = "0.8.2"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>", "<bfjelds@microsoft.com>"]
edition = "2018"

Expand Down
8 changes: 5 additions & 3 deletions agent/src/util/device_plugin_builder.rs
Expand Up @@ -140,7 +140,8 @@ impl DevicePluginBuilderInterface for DevicePluginBuilder {
UnixListener::bind(task_socket_path).expect("Failed to bind to socket path");

async_stream::stream! {
while let item = uds.accept().map_ok(|(st, _)| unix_stream::UnixStream(st)).await {
loop {
let item = uds.accept().map_ok(|(st, _)| unix_stream::UnixStream(st)).await;
yield item;
}
}
Expand Down Expand Up @@ -270,7 +271,8 @@ pub mod tests {
let uds = UnixListener::bind(socket).expect("Failed to bind to socket path");

async_stream::stream! {
while let item = uds.accept().map_ok(|(st, _)| unix_stream::UnixStream(st)).await {
loop {
let item = uds.accept().map_ok(|(st, _)| unix_stream::UnixStream(st)).await;
yield item;
}
}
Expand Down Expand Up @@ -348,7 +350,7 @@ pub mod tests {
});

// Make sure registration server has started
akri_shared::uds::unix_stream::try_connect(&kubelet_socket_str)
akri_shared::uds::unix_stream::try_connect(kubelet_socket_str)
.await
.unwrap();

Expand Down
15 changes: 8 additions & 7 deletions agent/src/util/device_plugin_service.rs
Expand Up @@ -83,7 +83,7 @@ pub struct DevicePluginService {
pub config_uid: String,
/// Namespace of Instance's Configuration CRD
pub config_namespace: String,
/// Instance is [not]shared
/// Instance is \[not\]shared
pub shared: bool,
/// Hostname of node this Device Plugin is running on
pub node_name: String,
Expand Down Expand Up @@ -340,11 +340,11 @@ impl DevicePluginService {
/// This returns the value that should be inserted at `device_usage_id` slot for an instance else an error.
/// # More details
/// Cases based on the usage slot (`device_usage_id`) value
/// 1. device_usage[id] == "" ... this means that the device is available for use
/// 1. device_usage\[id\] == "" ... this means that the device is available for use
/// * <ACTION> return this node name
/// 2. device_usage[id] == self.nodeName ... this means THIS node previously used id, but the DevicePluginManager knows that this is no longer true
/// 2. device_usage\[id\] == self.nodeName ... this means THIS node previously used id, but the DevicePluginManager knows that this is no longer true
/// * <ACTION> return ""
/// 3. device_usage[id] == <some other node> ... this means that we believe this device is in use by another node and should be marked unhealthy
/// 3. device_usage\[id\] == <some other node> ... this means that we believe this device is in use by another node and should be marked unhealthy
/// * <ACTION> return error
/// 4. No corresponding id found ... this is an unknown error condition (BAD)
/// * <ACTION> return error
Expand Down Expand Up @@ -893,10 +893,11 @@ mod device_plugin_service_tests {
.map(|x| format!("{}-{}", instance_name, x))
.collect();
assert_eq!(devices.len(), capacity);
// Can't use map on Device type
let device_ids: Vec<String> = devices.into_iter().map(|device| device.id).collect();
for device in expected_device_ids {
assert!(device_ids.contains(&device));
assert!(devices
.iter()
.map(|device| device.id.clone())
.any(|d| d == device));
}
}

Expand Down
2 changes: 1 addition & 1 deletion agent/src/util/discovery_operator.rs
Expand Up @@ -871,7 +871,7 @@ pub mod tests {
name: name.to_string(),
endpoint,
shared,
close_discovery_handler_connection: close_discovery_handler_connection,
close_discovery_handler_connection,
}
}

Expand Down
3 changes: 2 additions & 1 deletion agent/src/util/registration.rs
Expand Up @@ -186,7 +186,8 @@ pub async fn internal_run_registration_server(
tokio::net::UnixListener::bind(socket_path).expect("Failed to bind to socket path");

async_stream::stream! {
while let item = uds.accept().map_ok(|(st, _)| unix_stream::UnixStream(st)).await {
loop {
let item = uds.accept().map_ok(|(st, _)| unix_stream::UnixStream(st)).await;
yield item;
}
}
Expand Down
2 changes: 1 addition & 1 deletion controller/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "controller"
version = "0.8.1"
version = "0.8.2"
authors = ["<bfjelds@microsoft.com>", "<kagold@microsoft.com>"]
edition = "2018"

Expand Down
3 changes: 2 additions & 1 deletion controller/src/util/instance_action.rs
Expand Up @@ -334,6 +334,7 @@ mod handle_deletion_work_tests {
/// broker Pod, the broker Service, and the capability Service.
/// TODO: reduce parameters by passing Instance object instead of
/// individual fields
#[allow(clippy::too_many_arguments)]
async fn handle_addition_work(
instance_name: &str,
instance_uid: &str,
Expand Down Expand Up @@ -689,7 +690,7 @@ mod handle_instance_tests {
"\"startTime\": \"2020-02-25T20:48:03Z\"",
&format!(
"\"startTime\": \"{}\"",
start_time.format("%Y-%m-%dT%H:%M:%SZ").to_string()
start_time.format("%Y-%m-%dT%H:%M:%SZ")
),
);
let pods: PodList = serde_json::from_str(&start_time_adjusted_json).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion controller/src/util/node_watcher.rs
Expand Up @@ -550,7 +550,7 @@ mod tests {
"selfLink": ""
}
}"#;
fn listify_node(node_json: &String) -> String {
fn listify_node(node_json: &str) -> String {
format!("{}\n{}\n{}", LIST_PREFIX, node_json, LIST_SUFFIX)
}

Expand Down
5 changes: 5 additions & 0 deletions controller/src/util/pod_watcher.rs
Expand Up @@ -523,6 +523,7 @@ impl BrokerPodWatcher {
}

/// This creates new service or updates existing service with ownership.
#[allow(clippy::too_many_arguments)]
async fn create_or_update_service(
&self,
instance_name: &str,
Expand Down Expand Up @@ -1584,7 +1585,11 @@ mod tests {

#[derive(Clone)]
struct CleanupServices {
// This field is used for testing
#[allow(dead_code)]
find_svc_selector: &'static str,
// This field is used for testing
#[allow(dead_code)]
find_svc_result: &'static str,
cleanup_services: Vec<CleanupService>,
find_instance_id: &'static str,
Expand Down
2 changes: 1 addition & 1 deletion controller/src/util/shared_test_utils.rs
Expand Up @@ -57,7 +57,7 @@ pub mod config_for_tests {
"selfLink": ""
}
}"#;
fn listify_kube_object(node_json: &String) -> String {
fn listify_kube_object(node_json: &str) -> String {
format!("{}\n{}\n{}", LIST_PREFIX, node_json, LIST_SUFFIX)
}

Expand Down
4 changes: 2 additions & 2 deletions deployment/helm/Chart.yaml
Expand Up @@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.8.1
version: 0.8.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 0.8.1
appVersion: 0.8.2
@@ -1,6 +1,6 @@
[package]
name = "debug-echo-discovery-handler"
version = "0.8.1"
version = "0.8.2"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
@@ -1,6 +1,6 @@
[package]
name = "onvif-discovery-handler"
version = "0.8.1"
version = "0.8.2"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
@@ -1,6 +1,6 @@
[package]
name = "opcua-discovery-handler"
version = "0.8.1"
version = "0.8.2"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
@@ -1,6 +1,6 @@
[package]
name = "udev-discovery-handler"
version = "0.8.1"
version = "0.8.2"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/debug-echo/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "akri-debug-echo"
version = "0.8.1"
version = "0.8.2"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/onvif/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "akri-onvif"
version = "0.8.1"
version = "0.8.2"
authors = ["Kate Goldenring <kate.goldenring@microsoft.com>"]
edition = "2018"

Expand Down
4 changes: 2 additions & 2 deletions discovery-handlers/onvif/src/discovery_handler.rs
Expand Up @@ -108,7 +108,7 @@ impl DiscoveryHandler for DiscoveryHandlerImpl {
let futures: Vec<_> = latest_cameras
.iter()
.filter(|c| !previous_cameras.contains(c))
.map(|c| apply_filters(&discovery_handler_config, &c, &onvif_query))
.map(|c| apply_filters(&discovery_handler_config, c, &onvif_query))
.collect();
let options = futures_util::future::join_all(futures).await;
// Insert newly discovered camera that are not filtered out
Expand Down Expand Up @@ -154,7 +154,7 @@ async fn apply_filters(
) -> Option<(String, Device)> {
info!("apply_filters - device service url {}", device_service_uri);
let (ip_address, mac_address) = match onvif_query
.get_device_ip_and_mac_address(&device_service_uri)
.get_device_ip_and_mac_address(device_service_uri)
.await
{
Ok(ip_and_mac) => ip_and_mac,
Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/onvif/src/discovery_impl.rs
Expand Up @@ -304,7 +304,7 @@ pub mod util {

let envelope_as_string = create_onvif_discovery_message(&uuid_str);
socket
.send_to(&envelope_as_string.as_bytes(), multi_socket_addr)
.send_to(envelope_as_string.as_bytes(), multi_socket_addr)
.await?;
Ok(socket)
}
Expand Down
2 changes: 1 addition & 1 deletion discovery-handlers/onvif/src/discovery_utils.rs
Expand Up @@ -364,7 +364,7 @@ async fn inner_get_device_profile_streaming_uri(
/// Gets the streaming uri for a given profile for an ONVIF camera
async fn inner_is_device_responding(url: &str, http: &impl Http) -> Result<String, anyhow::Error> {
http.post(
&url,
url,
&get_action(DEVICE_WSDL, "GetSystemDateAndTime"),
&GET_SYSTEM_DATE_AND_TIME_TEMPLATE.to_string(),
)
Expand Down

0 comments on commit 4cad8e7

Please sign in to comment.