Skip to content

Commit

Permalink
chore: update rustc and nixpkgs (#20)
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro authored Feb 8, 2023
1 parent 44a3cfd commit 41a8ecf
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 79 deletions.
46 changes: 23 additions & 23 deletions composer/src/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Binary {
/// Add environment variables for the container
pub fn with_env(mut self, key: &str, val: &str) -> Self {
if let Some(old) = self.env.insert(key.into(), val.into()) {
println!("Replaced key {} val {} with val {}", key, old, val);
println!("Replaced key {key} val {old} with val {val}");
}
self
}
Expand All @@ -150,7 +150,7 @@ impl Binary {
if let Some(nats_arg) = self.nats_arg.take() {
if !nats_arg.is_empty() {
self.arguments.push(nats_arg);
self.arguments.push(format!("nats.{}:4222", network));
self.arguments.push(format!("nats.{network}:4222"));
}
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@ impl std::str::FromStr for ImagePullPolicy {
match source.to_ascii_lowercase().as_str() {
"ifnotpresent" => Ok(Self::IfNotPresent),
"always" => Ok(Self::Always),
_ => Err(format!("Could not parse the ImagePullPolicy: {}", source)),
_ => Err(format!("Could not parse the ImagePullPolicy: {source}")),
}
}
}
Expand Down Expand Up @@ -291,7 +291,7 @@ impl ContainerSpec {
let from = if from.contains('/') {
from.to_string()
} else {
format!("{}/tcp", from)
format!("{from}/tcp")
};
let binding = bollard::service::PortBinding {
host_ip: None,
Expand Down Expand Up @@ -330,7 +330,7 @@ impl ContainerSpec {
/// If a key already exists, the value is replaced
pub fn with_env(mut self, key: &str, val: &str) -> Self {
if let Some(old) = self.env.insert(key.into(), val.into()) {
println!("Replaced key {} val {} with val {}", key, old, val);
println!("Replaced key {key} val {old} with val {val}");
}
self
}
Expand Down Expand Up @@ -395,11 +395,11 @@ impl ContainerSpec {
fn binds(&self) -> Vec<String> {
let mut vec = vec![];
self.binds.iter().for_each(|(container, host)| {
vec.push(format!("{}:{}", host, container));
vec.push(format!("{host}:{container}"));
});
if let Some(binary) = &self.binary {
binary.binds.iter().for_each(|(container, host)| {
vec.push(format!("{}:{}", host, container));
vec.push(format!("{host}:{container}"));
});
}
vec.dedup();
Expand Down Expand Up @@ -438,7 +438,7 @@ impl ContainerSpec {
fn environment(&self) -> Vec<String> {
let mut vec = vec![];
self.env.iter().for_each(|(k, v)| {
vec.push(format!("{}={}", k, v));
vec.push(format!("{k}={v}"));
});
vec
}
Expand Down Expand Up @@ -624,7 +624,7 @@ impl Builder {
.map_err(|error| bollard::errors::Error::IOError {
err: std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("Invalid network format: {}", error),
format!("Invalid network format: {error}"),
),
})?;
Ok(self)
Expand Down Expand Up @@ -915,36 +915,36 @@ impl Drop for ComposeTest {
self.containers.keys().for_each(|name| {
tracing::error!("Logs from container '{}':", name);
let _ = std::process::Command::new("docker")
.args(&["logs", name])
.args(["logs", name])
.status();
});
}

if self.clean && (!thread::panicking() || self.allow_clean_on_panic) {
self.shutdown_order.iter().for_each(|c| {
std::process::Command::new("docker")
.args(&["kill", "-s", "term", c])
.args(["kill", "-s", "term", c])
.output()
.unwrap();
});

self.containers.keys().for_each(|c| {
std::process::Command::new("docker")
.args(&["kill", "-s", "term", c])
.args(["kill", "-s", "term", c])
.output()
.unwrap();
std::process::Command::new("docker")
.args(&["kill", c])
.args(["kill", c])
.output()
.unwrap();
std::process::Command::new("docker")
.args(&["rm", "-v", c])
.args(["rm", "-v", c])
.output()
.unwrap();
});

std::process::Command::new("docker")
.args(&["network", "rm", &self.name])
.args(["network", "rm", &self.name])
.output()
.unwrap();
}
Expand Down Expand Up @@ -1185,7 +1185,7 @@ impl ComposeTest {

let srcdir_str = self.srcdir.to_str().unwrap();
let mut binds = vec![
format!("{}:{}", srcdir_str, srcdir_str),
format!("{srcdir_str}:{srcdir_str}"),
"/dev/hugepages:/dev/hugepages:rw".into(),
];

Expand All @@ -1199,7 +1199,7 @@ impl ComposeTest {
bin.path.as_path()
};
let path = path.to_str().unwrap();
binds.push(format!("{}:{}", path, path));
binds.push(format!("{path}:{path}"));
}
if (spec.image.is_some() || self.image.is_some()) && spec.init.unwrap_or(true) {
if let Ok(tini) = Binary::which("tini") {
Expand Down Expand Up @@ -1257,7 +1257,7 @@ impl ComposeTest {
);

let mut env = spec.environment();
env.push(format!("MY_POD_IP={}", ipv4));
env.push(format!("MY_POD_IP={ipv4}"));

// figure out which ports to expose based on the port mapping
let mut exposed_ports = HashMap::new();
Expand Down Expand Up @@ -1368,7 +1368,7 @@ impl ComposeTest {
/// Pulls the docker image, if one is specified and is not present locally
async fn pull_missing_image(&self, image: &str) {
let image = if !image.contains(':') {
format!("{}:latest", image)
format!("{image}:latest")
} else {
image.to_string()
};
Expand Down Expand Up @@ -1443,7 +1443,7 @@ impl ComposeTest {
.ok_or(bollard::errors::Error::IOError {
err: std::io::Error::new(
std::io::ErrorKind::NotFound,
format!("Can't start container {} as it was not configured", name),
format!("Can't start container {name} as it was not configured"),
),
})?;
if !self.reuse || self.prune_matching {
Expand Down Expand Up @@ -1557,7 +1557,7 @@ impl ComposeTest {
.try_collect::<Vec<_>>()
.await?;

logs.iter().for_each(|l| print!("{}:{}", name, l));
logs.iter().for_each(|l| print!("{name}:{l}"));
Ok(())
}

Expand Down Expand Up @@ -1624,7 +1624,7 @@ impl ComposeTest {
for container in containers {
if let Some(id) = container.id {
if let Err(e) = self.stop_id(&id).await {
println!("Failed to stop container id {:?}", id);
println!("Failed to stop container id {id:?}");
result = Err(e);
}
}
Expand All @@ -1640,7 +1640,7 @@ impl ComposeTest {
for container in containers {
if let Some(id) = container.id {
if let Err(e) = self.restart_id(&id).await {
println!("Failed to restart container id {:?}", id);
println!("Failed to restart container id {id:?}");
result = Err(e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion devinfo/src/block_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl TryFrom<&str> for BlkDev {
}

let uuid = Uuid::parse_str(nq[1]).map_err(|e| NqnInvalid {
value: format!("the UUID is invalid {}", e),
value: format!("the UUID is invalid {e}"),
})?;

match value.scheme() {
Expand Down
4 changes: 2 additions & 2 deletions devinfo/src/mountinfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ impl MountInfo {
fn fetch_from_disk_by_path(path: &str) -> io::Result<PathBuf> {
PartitionID::from_disk_by_path(path)
.map_err(|why| Error::new(ErrorKind::InvalidData, format!("{}: {}", path, why)))?
.map_err(|why| Error::new(ErrorKind::InvalidData, format!("{path}: {why}")))?
.get_device_path()
.ok_or_else(|| {
Error::new(
ErrorKind::NotFound,
format!("device path for {} was not found", path),
format!("device path for {path} was not found"),
)
})
}
Expand Down
12 changes: 6 additions & 6 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8720c8492d2ad2f892a6e0a0064d6da2969aba4",
"sha256": "0lpnfb94qyrv7sw8vjrpdlrrn2n2q75r93mc8q5afm5a0pdzrkax",
"rev": "0874168639713f547c05947c76124f78441ea46c",
"sha256": "0gw5l5bj3zcgxhp7ki1jafy6sl5nk4vr43hal94lhi15kg2vfmfy",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/b8720c8492d2ad2f892a6e0a0064d6da2969aba4.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/0874168639713f547c05947c76124f78441ea46c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"rust-overlay": {
Expand All @@ -17,10 +17,10 @@
"homepage": "",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "b4fb0f8454fe4e6ebb0a564a28a87cc88cc3cb2c",
"sha256": "01912q23pd67q4adsl6b1ayi3kn92w0daj2dvihajmh8239iplf3",
"rev": "fce84890519f05703e4b1f4c70bf9bb118206ffd",
"sha256": "10c858gxxh5knvn6mi3s59kr1nx222rykrp6x38vykq93y3hq68m",
"type": "tarball",
"url": "https://github.com/oxalica/rust-overlay/archive/b4fb0f8454fe4e6ebb0a564a28a87cc88cc3cb2c.tar.gz",
"url": "https://github.com/oxalica/rust-overlay/archive/fce84890519f05703e4b1f4c70bf9bb118206ffd.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
4 changes: 2 additions & 2 deletions nvmeadm/src/nvme_namespaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl NvmeDevice {
/// error if the value for the structure could not be found.
fn new(p: &Path) -> Result<Self, NvmeError> {
let name = p.file_name().unwrap().to_str().unwrap();
let devpath = format!("/sys/block/{}", name);
let subsyspath = format!("/sys/block/{}/device", name);
let devpath = format!("/sys/block/{name}");
let subsyspath = format!("/sys/block/{name}/device");
let source = Path::new(devpath.as_str());
let subsys = Path::new(subsyspath.as_str());

Expand Down
Loading

0 comments on commit 41a8ecf

Please sign in to comment.