Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 90385c5

Browse files
committed
chore: lint fixes
Signed-off-by: Shane Utt <shaneutt@linux.com>
1 parent 2cdfe1b commit 90385c5

File tree

13 files changed

+43
-42
lines changed

13 files changed

+43
-42
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ check.format.rust: ## Check Rust code formatting
119119
cargo fmt --manifest-path Cargo.toml --all -- --check
120120

121121
.PHONY: lint
122-
lint: ## Lint Rust code
123-
cargo clippy --all -- -D warnings
122+
lint:
123+
cargo clippy --workspace --all-targets --all-features -- -D warnings
124124

125125
# ------------------------------------------------------------------------------
126126
# Testing

controlplane/src/client_manager.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ pub struct DataplaneClientManager {
3232
clients: Arc<RwLock<HashMap<String, BackendsClient<Channel>>>>,
3333
}
3434

35+
impl Default for DataplaneClientManager {
36+
fn default() -> Self {
37+
Self::new()
38+
}
39+
}
40+
3541
impl DataplaneClientManager {
3642
pub fn new() -> Self {
3743
Self {
@@ -62,16 +68,15 @@ impl DataplaneClientManager {
6268

6369
for pod in dataplane_pods {
6470
if let Some(pod_ip) = &pod.status.as_ref().and_then(|s| s.pod_ip.as_ref()) {
65-
let endpoint = format!("http://{}:9090", pod_ip);
71+
let endpoint = format!("http://{pod_ip}:9090");
6672
match BackendsClient::connect(endpoint.clone()).await {
6773
Ok(grpc_client) => {
6874
info!("Connected to dataplane pod: {}", pod_ip);
6975
new_clients.insert(pod_ip.to_string(), grpc_client);
7076
}
71-
Err(e) => {
77+
Err(err) => {
7278
return Err(crate::Error::DataplaneError(format!(
73-
"Failed to connect to dataplane pod {}: {}",
74-
pod_ip, e
79+
"Failed to connect to dataplane pod {pod_ip}: {err}"
7580
)));
7681
}
7782
}
@@ -97,10 +102,9 @@ impl DataplaneClientManager {
97102
Ok(_) => {
98103
info!("Successfully updated targets on dataplane pod: {}", pod_ip);
99104
}
100-
Err(e) => {
105+
Err(err) => {
101106
return Err(crate::Error::DataplaneError(format!(
102-
"Failed to update targets on dataplane pod {}: {}",
103-
pod_ip, e
107+
"Failed to update targets on dataplane pod {pod_ip}: {err}"
104108
)));
105109
}
106110
}
@@ -122,8 +126,8 @@ impl DataplaneClientManager {
122126
Ok(_) => {
123127
info!("Successfully deleted VIP on dataplane pod: {}", pod_ip);
124128
}
125-
Err(e) => {
126-
warn!("Failed to delete VIP on dataplane pod {}: {}", pod_ip, e);
129+
Err(err) => {
130+
warn!("Failed to delete VIP on dataplane pod {}: {}", pod_ip, err);
127131
}
128132
}
129133
}

controlplane/src/gateway_controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub async fn reconcile(gateway: Arc<Gateway>, ctx: Arc<Context>) -> Result<Actio
117117
// Try to fetch any existing Loadbalancer service(s) for this Gateway.
118118
let service_api: Api<Service> = Api::namespaced(client, &ns);
119119
let services = service_api
120-
.list(&ListParams::default().labels(&format!("{}={}", GATEWAY_SERVICE_LABEL, name)))
120+
.list(&ListParams::default().labels(&format!("{GATEWAY_SERVICE_LABEL}={name}")))
121121
.await
122122
.map_err(Error::KubeError)?;
123123

controlplane/src/gateway_utils.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub fn update_service_for_gateway(gateway: &Gateway, svc: &mut Service) -> Resul
225225
let addr = addresses[0].clone();
226226
if let Some(t) = addr.r#type {
227227
if t != "IPAddress" {
228-
return Err(Error::InvalidConfigError(format!("addresses of type {} are not supported; only type IPAddress is supported", t).to_string()));
228+
return Err(Error::InvalidConfigError(format!("addresses of type {t} are not supported; only type IPAddress is supported").to_string()));
229229
}
230230
}
231231
address = Some(addresses[0].clone());
@@ -353,8 +353,7 @@ pub fn get_accepted_condition(gateway: &Gateway) -> metav1::Condition {
353353
accepted.status = String::from("False");
354354
accepted.reason = GatewayConditionReason::UnsupportedAddress.to_string();
355355
accepted.message = format!(
356-
"found an addres of type {}, only type IPAddress is supported",
357-
addr_type
356+
"found an addres of type {addr_type}, only type IPAddress is supported"
358357
);
359358
break;
360359
}
@@ -615,7 +614,7 @@ fn check_route_kinds(
615614

616615
if let Some(group) = &rgk.group {
617616
if group.as_str() != "gateway.networking.k8s.io" {
618-
return Some(format!("Unsupported API group: {}", group));
617+
return Some(format!("Unsupported API group: {group}"));
619618
}
620619
}
621620
None

dataplane/api-server/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub async fn start(
4949
let addr = SocketAddrV4::new(addr, port);
5050
let server = server_builder.serve(addr.into(), health_service);
5151

52-
debug!("gRPC Health Checking service listens on {}", addr);
52+
debug!("gRPC Health Checking service listens on {addr}");
5353
server
5454
.await
5555
.expect("Failed to serve gRPC Health Checking service");
@@ -65,7 +65,7 @@ pub async fn start(
6565
let tls_addr = SocketAddrV4::new(addr, port);
6666
let tls_server = server_builder.serve(tls_addr.into(), BackendsServer::new(server));
6767

68-
debug!("TLS server listens on {}", tls_addr);
68+
debug!("TLS server listens on {tls_addr}");
6969
tls_server.await.expect("Failed to serve TLS");
7070
});
7171

dataplane/api-server/src/netutils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ pub fn if_index_for_routing_ip(ip_addr: Ipv4Addr) -> Result<u32, Error> {
7272
return Ok(*idex_if);
7373
}
7474
}
75-
Err(Error::msg(format!("{} {}", ERR_NO_IFINDEX, ip_addr)))
75+
Err(Error::msg(format!("{ERR_NO_IFINDEX} {ip_addr}")))
7676
}

dataplane/api-server/src/server.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::backends::backends_server::Backends;
1616
use crate::backends::{Confirmation, InterfaceIndexConfirmation, PodIp, Targets, Vip};
1717
use crate::netutils::if_index_for_routing_ip;
1818
use common::{
19-
Backend, BackendKey, BackendList, ClientKey, LoadBalancerMapping, BACKENDS_ARRAY_CAPACITY,
19+
BACKENDS_ARRAY_CAPACITY, Backend, BackendKey, BackendList, ClientKey, LoadBalancerMapping,
2020
};
2121

2222
pub struct BackendService {
@@ -133,9 +133,8 @@ impl Backends for BackendService {
133133
Ok(ifindex) => ifindex,
134134
Err(err) => {
135135
return Err(Status::internal(format!(
136-
"failed to determine ifindex: {}",
137-
err
138-
)))
136+
"failed to determine ifindex: {err}"
137+
)));
139138
}
140139
}
141140
}
@@ -163,13 +162,12 @@ impl Backends for BackendService {
163162
match self.insert_and_reset_index(key, backend_list).await {
164163
Ok(_) => Ok(Response::new(Confirmation {
165164
confirmation: format!(
166-
"success, vip {}:{} was updated with {} backends",
165+
"success, vip {}:{} was updated with {count} backends",
167166
Ipv4Addr::from(vip.ip),
168167
vip.port,
169-
count,
170168
),
171169
})),
172-
Err(err) => Err(Status::internal(format!("failure: {}", err))),
170+
Err(err) => Err(Status::internal(format!("failure: {err}"))),
173171
}
174172
}
175173

@@ -185,14 +183,14 @@ impl Backends for BackendService {
185183

186184
match self.remove(key).await {
187185
Ok(()) => Ok(Response::new(Confirmation {
188-
confirmation: format!("success, vip {}:{} was deleted", addr_ddn, vip.port),
186+
confirmation: format!("success, vip {addr_ddn}:{} was deleted", vip.port),
189187
})),
190188
Err(err) if err.to_string().contains("syscall failed with code -1") => {
191189
Ok(Response::new(Confirmation {
192-
confirmation: format!("success, vip {}:{} did not exist", addr_ddn, vip.port),
190+
confirmation: format!("success, vip {addr_ddn}:{} did not exist", vip.port),
193191
}))
194192
}
195-
Err(err) => Err(Status::internal(format!("failure: {}", err))),
193+
Err(err) => Err(Status::internal(format!("failure: {err}"))),
196194
}
197195
}
198196
}

dataplane/loader/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async fn main() -> Result<(), anyhow::Error> {
7979
"../../target/bpfel-unknown-none/release/loader"
8080
))?;
8181
if let Err(e) = EbpfLogger::init(&mut bpf_program) {
82-
warn!("failed to initialize eBPF logger: {}", e);
82+
warn!("failed to initialize eBPF logger: {e}");
8383
}
8484

8585
info!("attaching tc_ingress program to {}", &opt.iface);

tools/udp-test-server/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3333
}
3434

3535
async fn run_server(port: u16, start_notifier: Sender<u16>) -> std::io::Result<()> {
36-
let bindaddr = format!("0.0.0.0:{}", port);
36+
let bindaddr = format!("0.0.0.0:{port}");
3737
let sock = UdpSocket::bind(&bindaddr).await?;
3838

3939
if let Err(err) = start_notifier.send(port).await {
@@ -43,7 +43,7 @@ async fn run_server(port: u16, start_notifier: Sender<u16>) -> std::io::Result<(
4343
let mut buf = [0; 1024];
4444
loop {
4545
let (len, addr) = sock.recv_from(&mut buf).await?;
46-
println!("port {}: {} bytes received from {}", port, len, addr);
46+
println!("port {port}: {len} bytes received from {addr}");
4747
println!(
4848
"port {}: buffer contents: {}",
4949
port,
@@ -53,19 +53,19 @@ async fn run_server(port: u16, start_notifier: Sender<u16>) -> std::io::Result<(
5353
}
5454

5555
async fn run_health_server(port: u16, mut rx: Receiver<u16>) -> std::io::Result<()> {
56-
let bindaddr = format!("0.0.0.0:{}", port);
56+
let bindaddr = format!("0.0.0.0:{port}");
5757
let listener = TcpListener::bind(&bindaddr).await?;
5858

5959
println!("waiting for listeners...");
6060
let mut wait_for = 3;
6161
while wait_for > 0 {
6262
if let Some(port) = rx.recv().await {
63-
println!("UDP worker listening on port {}", port);
63+
println!("UDP worker listening on port {port}");
6464
wait_for -= 1;
6565
};
6666
}
6767

68-
println!("health check server listening on {}", port);
68+
println!("health check server listening on {port}");
6969

7070
let mut peers = Peers::default();
7171
loop {
@@ -87,7 +87,7 @@ impl Peers {
8787
}
8888

8989
if !self.peers.contains(&addr.ip()) {
90-
println!("received health check from {}", addr);
90+
println!("received health check from {addr}");
9191
self.peers.push(addr.ip());
9292
}
9393
}

xtask/src/build_proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Options {}
1212
pub(crate) fn build_proto(_opts: Options) -> Result<(), anyhow::Error> {
1313
let proto_file = "./dataplane/api-server/proto/backends.proto";
1414

15-
println!("building proto {}", proto_file);
15+
println!("building proto {proto_file}");
1616

1717
tonic_build::configure()
1818
.protoc_arg("--experimental_allow_proto3_optional")

0 commit comments

Comments
 (0)