Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -1037,7 +1037,7 @@ dependencies = [
"hyper",
"libc",
"pin-project-lite",
"socket2 0.5.10",
"socket2 0.6.0",
"tokio",
"tower-service",
"tracing",
Expand Down
2 changes: 1 addition & 1 deletion policy-controller/k8s/index/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}")),
}
}
}
Expand Down
30 changes: 11 additions & 19 deletions policy-controller/k8s/index/src/inbound/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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}");
}
}

Expand Down
9 changes: 3 additions & 6 deletions policy-controller/k8s/index/src/outbound/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ fn parse_duration(s: &str) -> Result<time::Duration> {
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::<u64>()?;

Expand All @@ -1990,14 +1990,11 @@ fn parse_duration(s: &str) -> Result<time::Duration> {
"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))
}
2 changes: 1 addition & 1 deletion policy-controller/k8s/status/src/resource_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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})")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion policy-controller/runtime/src/admission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl Validate<MeshTLSAuthenticationSpec> 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}");
}
}

Expand Down