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
4 changes: 2 additions & 2 deletions crates/cli/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ pub fn run(build: &str) -> Result<(), String> {
let tmpdir = scratch().map_err(|err| format!("failed to create tempdir: {err}"))?;
let script = tmpdir.join(name);

let dl = Command::new("curl")
let fetched = Command::new("curl")
.args(["-fsSL", "--max-time", &INSTALL.to_string(), "-o"])
.arg(&script)
.arg(&url)
.status()
.map_err(|err| format!("failed to invoke curl: {err}"))?;
if !dl.success() {
if !fetched.success() {
let _ = fs::remove_dir_all(&tmpdir);
return Err(format!("failed to download manager from {url}"));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/tests/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn scratch(name: &str) -> std::path::PathBuf {
#[test]
fn omitted() {
let listener = TcpListener::bind("127.0.0.1:0").expect("tcp listener should bind");
let address = listener.local_addr().expect("listener address");
let addr = listener.local_addr().expect("listener address");
let (tx, rx) = mpsc::channel();

let handle = std::thread::spawn(move || {
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace = "inspect-payload"
name = "server"
command = "sh"
args = ["-c", "sleep 1"]
inspect_socket = "tcp://{address}"
inspect_socket = "tcp://{addr}"
"#
),
)
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn send(

let raw = match endpoint {
socket::Endpoint::Unix(path) => unix(path, &line, timeout)?,
socket::Endpoint::Tcp(address) => tcp(address, &line, timeout)?,
socket::Endpoint::Tcp(addr) => tcp(addr, &line, timeout)?,
};
parse(&raw, &id)
}
Expand Down Expand Up @@ -118,8 +118,8 @@ fn unix(
Err("unix inspect transport is not available on this platform".to_string())
}

fn tcp(address: &str, line: &str, timeout: Option<Duration>) -> Result<String, String> {
let mut stream = TcpStream::connect(address).map_err(|err| err.to_string())?;
fn tcp(addr: &str, line: &str, timeout: Option<Duration>) -> Result<String, String> {
let mut stream = TcpStream::connect(addr).map_err(|err| err.to_string())?;
if let Some(timeout) = timeout {
let _ = stream.set_read_timeout(Some(timeout));
let _ = stream.set_write_timeout(Some(timeout));
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/runtime/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Stamped {

#[doc(hidden)]
pub fn filter(rows: Vec<(u32, String)>, app: Option<&str>, namespace: &str) -> Vec<Stamped> {
sift(rows, |args| {
filter(rows, |args| {
stamp::find(args).is_some_and(|stamp| {
app.is_none_or(|name| stamp.app == name) && stamp.namespace == namespace
})
Expand All @@ -42,7 +42,7 @@ impl Broker {

#[doc(hidden)]
pub fn filter(rows: Vec<(u32, String)>, project: &str, namespace: &str) -> Vec<Broker> {
sift(rows, |args| {
filter(rows, |args| {
broker::find(args).is_some_and(|identity| {
identity.project == project && identity.namespace == namespace
})
Expand All @@ -53,7 +53,7 @@ impl Broker {
}
}

fn sift<F>(rows: Vec<(u32, String)>, predicate: F) -> Vec<(u32, String)>
fn filter<F>(rows: Vec<(u32, String)>, predicate: F) -> Vec<(u32, String)>
where
F: Fn(&[String]) -> bool,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/runtime/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ pub fn table(
if columns[3] != "0A" || !inodes.contains(columns[9]) {
continue;
}
addrs.push(address(columns[1])?);
addrs.push(addr(columns[1])?);
}
Ok(addrs)
}

#[cfg(target_os = "linux")]
fn address(value: &str) -> Result<SocketAddr, String> {
fn addr(value: &str) -> Result<SocketAddr, String> {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

let (addr, port) = value
Expand Down
14 changes: 7 additions & 7 deletions crates/core/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ impl Endpoint {
return Ok(Self::Unix(PathBuf::from(path)));
}

if let Some(address) = value.strip_prefix(TCP) {
validate(address)?;
return Ok(Self::Tcp(address.to_string()));
if let Some(addr) = value.strip_prefix(TCP) {
validate(addr)?;
return Ok(Self::Tcp(addr.to_string()));
}

Err(Error::new(
Expand All @@ -48,7 +48,7 @@ impl std::fmt::Display for Endpoint {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Unix(path) => write!(formatter, "unix://{}", path.display()),
Self::Tcp(address) => write!(formatter, "{TCP}{address}"),
Self::Tcp(addr) => write!(formatter, "{TCP}{addr}"),
}
}
}
Expand All @@ -69,11 +69,11 @@ impl std::fmt::Display for Error {

impl std::error::Error for Error {}

fn validate(address: &str) -> Result<(), Error> {
if address.trim().is_empty() {
fn validate(addr: &str) -> Result<(), Error> {
if addr.trim().is_empty() {
return Err(Error::new("tcp socket endpoint must include host:port"));
}
if !address.contains(':') {
if !addr.contains(':') {
return Err(Error::new("tcp socket endpoint must include a port"));
}
Ok(())
Expand Down
Loading