diff --git a/Cargo.lock b/Cargo.lock index 94ea1ee10f67a..50cb1c58534b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,9 +62,9 @@ checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anyhow" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "async-broadcast" @@ -1037,7 +1037,7 @@ dependencies = [ "hyper", "libc", "pin-project-lite", - "socket2 0.5.10", + "socket2 0.6.0", "tokio", "tower-service", "tracing", diff --git a/policy-controller/k8s/index/src/defaults.rs b/policy-controller/k8s/index/src/defaults.rs index 96f0c22aa9cef..d58f1832adc26 100644 --- a/policy-controller/k8s/index/src/defaults.rs +++ b/policy-controller/k8s/index/src/defaults.rs @@ -51,7 +51,7 @@ impl std::str::FromStr for DefaultPolicy { }), "deny" => Ok(Self::Deny), "audit" => Ok(Self::Audit), - s => Err(anyhow!("invalid mode: {:?}", s)), + s => Err(anyhow!("invalid mode: {s:?}")), } } } diff --git a/policy-controller/k8s/index/src/inbound/index.rs b/policy-controller/k8s/index/src/inbound/index.rs index edbb07780eab3..b80dbd2eac8da 100644 --- a/policy-controller/k8s/index/src/inbound/index.rs +++ b/policy-controller/k8s/index/src/inbound/index.rs @@ -209,12 +209,12 @@ impl Index { .namespaces .by_ns .get_mut(namespace) - .ok_or_else(|| anyhow::anyhow!("namespace not found: {}", namespace))?; + .ok_or_else(|| anyhow::anyhow!("namespace not found: {namespace}"))?; let pod = ns .pods .by_name .get_mut(pod) - .ok_or_else(|| anyhow::anyhow!("pod {}.{} not found", pod, namespace))?; + .ok_or_else(|| anyhow::anyhow!("pod {pod}.{namespace} not found"))?; Ok(pod .port_server_or_default(port, &self.cluster_info) .watch @@ -235,14 +235,12 @@ impl Index { .namespaces .by_ns .get_mut(namespace) - .ok_or_else(|| anyhow::anyhow!("namespace not found: {}", namespace))?; - let external_workload = - ns.external_workloads - .by_name - .get_mut(workload) - .ok_or_else(|| { - anyhow::anyhow!("external workload {}.{} not found", workload, namespace) - })?; + .ok_or_else(|| anyhow::anyhow!("namespace not found: {namespace}"))?; + let external_workload = ns + .external_workloads + .by_name + .get_mut(workload) + .ok_or_else(|| anyhow::anyhow!("external workload {workload}.{namespace} not found"))?; Ok(external_workload .port_server_or_default(port, &self.cluster_info) .watch @@ -1195,7 +1193,7 @@ impl PodIndex { // Pod labels and annotations may change at runtime, but the // port list may not if pod.port_names != port_names { - bail!("pod {} port names must not change", name); + bail!("pod {name} port names must not change"); } // If there aren't meaningful changes, then don't bother doing @@ -2060,9 +2058,7 @@ impl PolicyIndex { .and_then(|ns| ns.meshtls.get(name)) .ok_or_else(|| { anyhow!( - "could not find MeshTLSAuthentication {} in namespace {}", - name, - namespace + "could not find MeshTLSAuthentication {name} in namespace {namespace}" ) })?; tracing::trace!(ids = ?authn.matches, "Found MeshTLSAuthentication"); @@ -2111,11 +2107,7 @@ impl PolicyIndex { continue; } } - bail!( - "could not find NetworkAuthentication {} in namespace {}", - name, - namespace - ); + bail!("could not find NetworkAuthentication {name} in namespace {namespace}"); } } diff --git a/policy-controller/k8s/index/src/outbound/index.rs b/policy-controller/k8s/index/src/outbound/index.rs index db0fd8fe6e0d0..09e980560ab0c 100644 --- a/policy-controller/k8s/index/src/outbound/index.rs +++ b/policy-controller/k8s/index/src/outbound/index.rs @@ -1979,7 +1979,7 @@ fn parse_duration(s: &str) -> Result { let s = s.trim(); let offset = s .rfind(|c: char| c.is_ascii_digit()) - .ok_or_else(|| anyhow::anyhow!("{} does not contain a timeout duration value", s))?; + .ok_or_else(|| anyhow::anyhow!("{s} does not contain a timeout duration value"))?; let (magnitude, unit) = s.split_at(offset + 1); let magnitude = magnitude.parse::()?; @@ -1990,14 +1990,11 @@ fn parse_duration(s: &str) -> Result { "m" => 1000 * 60, "h" => 1000 * 60 * 60, "d" => 1000 * 60 * 60 * 24, - _ => bail!( - "invalid duration unit {} (expected one of 'ms', 's', 'm', 'h', or 'd')", - unit - ), + _ => bail!("invalid duration unit {unit} (expected one of 'ms', 's', 'm', 'h', or 'd')"), }; let ms = magnitude .checked_mul(mul) - .ok_or_else(|| anyhow::anyhow!("Timeout value {} overflows when converted to 'ms'", s))?; + .ok_or_else(|| anyhow::anyhow!("Timeout value {s} overflows when converted to 'ms'"))?; Ok(time::Duration::from_millis(ms)) } diff --git a/policy-controller/k8s/status/src/resource_id.rs b/policy-controller/k8s/status/src/resource_id.rs index 24549f06a0abb..d425be1162f02 100644 --- a/policy-controller/k8s/status/src/resource_id.rs +++ b/policy-controller/k8s/status/src/resource_id.rs @@ -36,7 +36,7 @@ impl NamespaceGroupKindName { (GATEWAY_API_GROUP, "TCPRoute") => Ok(gateway::TCPRoute::api_version(&())), (GATEWAY_API_GROUP, "TLSRoute") => Ok(gateway::TLSRoute::api_version(&())), (group, kind) => { - anyhow::bail!("unknown group + kind combination: ({}, {})", group, kind) + anyhow::bail!("unknown group + kind combination: ({group}, {kind})") } } } diff --git a/policy-controller/runtime/src/admission.rs b/policy-controller/runtime/src/admission.rs index 1af3e44abf7fe..0669790fbc71b 100644 --- a/policy-controller/runtime/src/admission.rs +++ b/policy-controller/runtime/src/admission.rs @@ -321,7 +321,7 @@ impl Validate for Admission { ) -> Result<()> { for id in spec.identities.iter().flatten() { if let Err(err) = validation::validate_identity(id) { - bail!("id {} is invalid: {}", id, err); + bail!("id {id} is invalid: {err}"); } }