Skip to content

Commit

Permalink
refactor(simulator): fix build, resolve warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdeafbeef authored and Rexagon committed May 6, 2024
1 parent 11fcf35 commit 0ed4fa4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion simulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ anyhow = { workspace = true }
clap = { workspace = true }
hex = { workspace = true }
rand = { workspace = true }
serde = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }

tycho-util = { workspace = true }
Expand Down
5 changes: 2 additions & 3 deletions simulator/src/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::ffi::OsStr;
use std::path::PathBuf;
use std::process::{Command, Output, Stdio};
use std::str;
use std::str::FromStr;

use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -152,7 +151,7 @@ impl ComposeRunner {
for i in self.get_running_nodes_list()? {
println!("node {i}");
let index = i
.split("-")
.split('-')
.collect::<Vec<&str>>()
.last()
.unwrap()
Expand All @@ -175,7 +174,7 @@ impl ComposeRunner {
let output = self.execute_compose_command(&docker_compose_command)?;
let x = String::from_utf8(output.stdout)?
.trim()
.split("\n")
.lines()
.map(|x| x.to_string())
.collect();
Ok(x)
Expand Down
2 changes: 1 addition & 1 deletion simulator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::unused_self)]
#![allow(clippy::unused_self, clippy::print_stdout, clippy::print_stderr)]

use std::process::Command;

Expand Down
9 changes: 4 additions & 5 deletions simulator/src/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::net::Ipv4Addr;
use std::os::unix::fs::PermissionsExt;
use std::str::FromStr;

use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};

use crate::compose::{ComposeRunner, Service};
use crate::compose::ComposeRunner;
use crate::config::ServiceConfig;
use crate::node::{Node, NodeOptions};

Expand Down Expand Up @@ -41,7 +40,7 @@ impl Simulator {
let mut ips = Vec::new();
for node_index in 0..nodes {
let ip = self.add_node(node_index, None, None)?;
ips.push(ip)
ips.push(ip);
}

//self.add_grafana()?;
Expand Down Expand Up @@ -133,7 +132,7 @@ datasources:
editable: true
"#;
let grafana_datasource_config = self.config.grafana().join("datasource.yml");
std::fs::write(&grafana_datasource_config, grafana_data)
std::fs::write(grafana_datasource_config, grafana_data)
.context("Failed to write grafana data")?;

Ok(())
Expand Down Expand Up @@ -172,7 +171,7 @@ scrape_configs:
nodes
);
let prometheus_datasource_config = self.config.prometheus().join("prometheus.yml");
std::fs::write(&prometheus_datasource_config, prometheus_data)
std::fs::write(prometheus_datasource_config, prometheus_data)
.context("Failed to write prometheus data")?;
Ok(())
}
Expand Down

0 comments on commit 0ed4fa4

Please sign in to comment.