Skip to content

Commit

Permalink
chore: Run cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelOnFira committed Apr 18, 2024
1 parent 523a508 commit 3d94f9c
Show file tree
Hide file tree
Showing 39 changed files with 94 additions and 94 deletions.
6 changes: 3 additions & 3 deletions lib/convert/src/convert/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn handle(
.iter()
.find(|presence| presence.user_id == user.user_id));
let user_presence = unwrap_ref!(user_presence.presence);
let status = unwrap!(backend::user::Status::from_i32(user_presence.status));
let _status = unwrap!(backend::user::Status::from_i32(user_presence.status));

Ok(models::IdentityHandle {
identity_id: user_id,
Expand All @@ -47,7 +47,7 @@ pub fn handle_without_presence(
user: &backend::user::User,
) -> GlobalResult<models::IdentityHandle> {
let user_id = unwrap_ref!(user.user_id).as_uuid();
let is_self = user_id == current_user_id;
let _is_self = user_id == current_user_id;

Ok(models::IdentityHandle {
identity_id: user_id,
Expand Down Expand Up @@ -179,7 +179,7 @@ pub fn profile(
.iter()
.find(|presence| presence.user_id == user.user_id));
let user_presence = unwrap_ref!(user_presence.presence);
let status = unwrap!(backend::user::Status::from_i32(user_presence.status));
let _status = unwrap!(backend::user::Status::from_i32(user_presence.status));

let current_user_id = Into::<common::Uuid>::into(current_user_id);
let following = pctx.mutual_follows.iter().any(|follow| {
Expand Down
2 changes: 1 addition & 1 deletion lib/convert/src/fetch/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub async fn users(
pub async fn presence_data(
ctx: &OperationContext<()>,
user_ids: Vec<common::Uuid>,
summary_info: bool,
_summary_info: bool,
) -> GlobalResult<PresencesCtx> {
let ((presences_res, game_ids),) = tokio::try_join!(presences_and_game_ids(ctx, user_ids),)?;

Expand Down
2 changes: 1 addition & 1 deletion lib/convert/src/impls/admin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use proto::backend;
use rivet_operation::prelude::*;
use rivet_api::models;
use rivet_operation::prelude::*;

use crate::ApiFrom;

Expand Down
4 changes: 2 additions & 2 deletions lib/convert/src/impls/cloud/version/matchmaker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ pub async fn config_to_proto(

let regions_list = op!([ctx] region_list_for_game {
game_ids: vec![game_id.into()],
}).await?;
})
.await?;
let regions_res = op!([ctx] region_get {
region_ids: regions_list.region_ids.clone(),
})
Expand Down Expand Up @@ -335,7 +336,6 @@ impl ApiTryFrom<backend::captcha::captcha_config::Hcaptcha>
}
}


impl ApiFrom<models::CloudVersionMatchmakerCaptchaTurnstile>
for backend::captcha::captcha_config::Turnstile
{
Expand Down
24 changes: 11 additions & 13 deletions lib/util/core/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,32 @@ pub fn item_list<'a, I: Iterator<Item = impl AsRef<str>>>(mut iter: I) -> String
s.push_str(", ");
s.push_str(item.as_ref());
}

s

s
}

pub fn str_to_ident(
s: impl AsRef<str>,
) -> String {
pub fn str_to_ident(s: impl AsRef<str>) -> String {
let s = s.as_ref().to_ascii_lowercase();
let mut last_was_underscore = false;

let dashed = s.chars().filter_map(|c| {
match c {
let dashed = s
.chars()
.filter_map(|c| match c {
'0'..='9' | 'a'..='z' => {
last_was_underscore = false;
last_was_underscore = false;

Some(c)
},
}
_ => {
if !last_was_underscore {
last_was_underscore = true;
Some('-')
} else {
None
None
}
}
}
}).collect::<String>();
})
.collect::<String>();

dashed.trim_matches('-').to_string()
}
14 changes: 11 additions & 3 deletions lib/util/core/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod gg {

use ipnet::{Ipv4AddrRange, Ipv4Net};

use super::{default_firewall, FirewallRule, job};
use super::{default_firewall, job, FirewallRule};

pub fn vlan_ip_net() -> Ipv4Net {
Ipv4Net::new(Ipv4Addr::new(10, 0, 0, 0), 26).unwrap()
Expand Down Expand Up @@ -76,15 +76,23 @@ pub mod gg {
// Dynamic TCP
FirewallRule {
label: "dynamic-tcp".into(),
ports: format!("{}-{}", job::MIN_INGRESS_PORT_TCP, job::MAX_INGRESS_PORT_TCP),
ports: format!(
"{}-{}",
job::MIN_INGRESS_PORT_TCP,
job::MAX_INGRESS_PORT_TCP
),
protocol: "tcp".into(),
inbound_ipv4_cidr: vec!["0.0.0.0/0".into()],
inbound_ipv6_cidr: vec!["::/0".into()],
},
// Dynamic UDP
FirewallRule {
label: "dynamic-udp".into(),
ports: format!("{}-{}", job::MIN_INGRESS_PORT_UDP, job::MAX_INGRESS_PORT_UDP),
ports: format!(
"{}-{}",
job::MIN_INGRESS_PORT_UDP,
job::MAX_INGRESS_PORT_UDP
),
protocol: "udp".into(),
inbound_ipv4_cidr: vec!["0.0.0.0/0".into()],
inbound_ipv6_cidr: vec!["::/0".into()],
Expand Down
9 changes: 5 additions & 4 deletions lib/util/env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ pub mod cloudflare {
pub fn auth_token() -> &'static str {
match &*CLOUDFLARE_AUTH_TOKEN {
Some(x) => x.as_str(),
None => panic!("{}", EnvVarError::Missing("CLOUDFLARE_AUTH_TOKEN".to_string())),
None => panic!(
"{}",
EnvVarError::Missing("CLOUDFLARE_AUTH_TOKEN".to_string())
),
}
}

Expand Down Expand Up @@ -228,9 +231,7 @@ pub async fn read_secret(key: &[impl AsRef<str>]) -> Result<String, EnvVarError>
var(secret_env_var_key(key))
}

pub async fn read_secret_opt(
key: &[impl AsRef<str>],
) -> Result<Option<String>, EnvVarError> {
pub async fn read_secret_opt(key: &[impl AsRef<str>]) -> Result<Option<String>, EnvVarError> {
let env_var = read_secret(key).await;

match env_var {
Expand Down
2 changes: 1 addition & 1 deletion svc/api/admin/src/route/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct ServerIpsQuery {

pub async fn server_ips(
ctx: Ctx<Auth>,
watch_index: WatchIndexQuery,
_watch_index: WatchIndexQuery,
query: ServerIpsQuery,
) -> GlobalResult<models::AdminClusterGetServerIpsResponse> {
if query.server_id.is_none() && query.pool.is_none() {
Expand Down
4 changes: 2 additions & 2 deletions svc/api/cloud/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Auth {
let claims = self.claims()?;

if claims.as_user().is_ok() {
let (user, user_ent) = self.user(ctx).await?;
let (_user, user_ent) = self.user(ctx).await?;

assert::user_registered(ctx, user_ent.user_id).await?;

Expand Down Expand Up @@ -198,7 +198,7 @@ impl Auth {
let claims = self.claims()?;

if claims.as_user().is_ok() {
let (user, user_ent) = self.user(ctx).await?;
let (_user, user_ent) = self.user(ctx).await?;

assert::user_registered(ctx, user_ent.user_id).await?;

Expand Down
2 changes: 1 addition & 1 deletion svc/pkg/captcha/ops/hcaptcha-config-get/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use proto::backend::{self, pkg::*};
use proto::backend::pkg::*;
use rivet_operation::prelude::*;

#[operation(name = "captcha-hcaptcha-config-get")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chirp_worker::prelude::*;

#[worker_test]
async fn basic(ctx: TestCtx) {
async fn basic(_ctx: TestCtx) {
// TODO:
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use proto::backend::{self, pkg::*};
use proto::backend::pkg::*;
use rivet_operation::prelude::*;

#[derive(sqlx::FromRow)]
Expand Down
3 changes: 1 addition & 2 deletions svc/pkg/cluster/ops/server-get/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use chirp_worker::prelude::*;
use proto::backend::pkg::*;

#[worker_test]
async fn empty(ctx: TestCtx) {
async fn empty(_ctx: TestCtx) {
// TODO:
}
3 changes: 1 addition & 2 deletions svc/pkg/cluster/ops/server-list/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use chirp_worker::prelude::*;
use proto::backend::pkg::*;

#[worker_test]
async fn empty(ctx: TestCtx) {
async fn empty(_ctx: TestCtx) {
// TODO:
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use chirp_worker::prelude::*;
use proto::backend::pkg::*;

#[worker_test]
async fn empty(ctx: TestCtx) {
async fn empty(_ctx: TestCtx) {
// TODO:
}
34 changes: 22 additions & 12 deletions svc/pkg/cluster/util/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use tokio::{fs, process::Command};
use sha2::{Digest, Sha256};
use tokio::{fs, process::Command};

// NOTE: This only gets the hash of the folder. Any template variables changed in the install scripts
// will not update the hash.
Expand All @@ -22,13 +22,23 @@ async fn main() {

let mut util_path = std::env::current_dir().unwrap();
util_path.pop();
let util_path = util_path.join("worker").join("src").join("workers").join("server_install");
let util_path = util_path
.join("worker")
.join("src")
.join("workers")
.join("server_install");

// Compute the git diff between the current branch and the local changes
let cmd = Command::new("git").arg("diff").arg("--minimal").arg("HEAD").arg("--").arg(util_path).output()
.await
.unwrap();

let cmd = Command::new("git")
.arg("diff")
.arg("--minimal")
.arg("HEAD")
.arg("--")
.arg(util_path)
.output()
.await
.unwrap();

if !cmd.status.success() {
panic!(
"failed to get git diff ({}):\n{}",
Expand All @@ -42,11 +52,11 @@ async fn main() {
// If there is no diff, use the git commit hash
let source_hash = if source_diff.is_empty() {
let cmd = Command::new("git")
.arg("rev-parse")
.arg("HEAD:svc/pkg/cluster/worker/src/workers/server_install")
.output()
.await
.unwrap();
.arg("rev-parse")
.arg("HEAD:svc/pkg/cluster/worker/src/workers/server_install")
.output()
.await
.unwrap();

if !cmd.status.success() {
panic!(
Expand All @@ -55,7 +65,7 @@ async fn main() {
String::from_utf8(cmd.stderr).unwrap()
);
}

String::from_utf8(cmd.stdout).unwrap()
} else {
// Get hash of diff
Expand Down
9 changes: 4 additions & 5 deletions svc/pkg/cluster/util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ pub struct JobNodeConfig {
}

impl JobNodeConfig {
pub fn from_linode(instance_type: &linode::instance_type_get::response::InstanceType) -> JobNodeConfig {
pub fn from_linode(
instance_type: &linode::instance_type_get::response::InstanceType,
) -> JobNodeConfig {
// Account for kernel memory overhead
// https://www.linode.com/community/questions/17791/why-doesnt-free-m-match-the-full-amount-of-ram-of-my-nanode-plan
let memory = instance_type.memory * 96 / 100;
Expand Down Expand Up @@ -70,8 +72,5 @@ pub fn server_name(
backend::cluster::PoolType::Ats => "ats",
};

format!(
"{ns}-{provider_datacenter_id}-{pool_type_str}-{server_id}",
)
format!("{ns}-{provider_datacenter_id}-{pool_type_str}-{server_id}",)
}

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub async fn gen_install(

// This script is run by systemd on startup and gets the server's data from the Rivet API
pub async fn gen_hook(server_token: &str) -> GlobalResult<String> {
let mut script = vec![components::rivet_fetch_info(server_token)?];
let script = vec![components::rivet_fetch_info(server_token)?];

let joined = script.join("\n\necho \"======\"\n\n");
Ok(format!("#!/usr/bin/env bash\nset -eu\n\n{joined}"))
Expand Down
2 changes: 1 addition & 1 deletion svc/pkg/cluster/worker/tests/server_install_complete.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chirp_worker::prelude::*;

#[worker_test]
async fn server_install_complete(ctx: TestCtx) {
async fn server_install_complete(_ctx: TestCtx) {
// msg!([ctx] cluster::msg::server_install_complete() {

// })
Expand Down
2 changes: 1 addition & 1 deletion svc/pkg/cluster/worker/tests/server_undrain.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chirp_worker::prelude::*;

#[worker_test]
async fn server_undrain(ctx: TestCtx) {
async fn server_undrain(_ctx: TestCtx) {
if !util::feature::server_provision() {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion svc/pkg/job-run/ops/metrics-log/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use indoc::formatdoc;
use proto::backend::pkg::*;
use reqwest::StatusCode;

use rivet_operation::prelude::*;
use serde::Deserialize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum TaskState {
async fn worker(
ctx: &OperationContext<nomad::msg::monitor_alloc_update::Message>,
) -> GlobalResult<()> {
let crdb = ctx.crdb().await?;
let _crdb = ctx.crdb().await?;

let AllocationUpdated { allocation: alloc } = serde_json::from_str(&ctx.payload_json)?;
let alloc_state_json = serde_json::to_value(&alloc)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct RunRow {
async fn worker(
ctx: &OperationContext<nomad::msg::monitor_eval_update::Message>,
) -> GlobalResult<()> {
let crdb = ctx.crdb().await?;
let _crdb = ctx.crdb().await?;

let payload_value = serde_json::from_str::<serde_json::Value>(&ctx.payload_json)?;
let PlanResult { evaluation: eval } = serde_json::from_str::<PlanResult>(&ctx.payload_json)?;
Expand Down
2 changes: 0 additions & 2 deletions svc/pkg/job-run/worker/tests/nomad_monitor_alloc_plan.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use chirp_worker::prelude::*;

// #[worker_test]
// async fn basic(_ctx: TestCtx) {
// // TODO:
Expand Down
2 changes: 0 additions & 2 deletions svc/pkg/job-run/worker/tests/nomad_monitor_alloc_update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use chirp_worker::prelude::*;

// #[worker_test]
// async fn basic(_ctx: TestCtx) {
// // TODO:
Expand Down
2 changes: 0 additions & 2 deletions svc/pkg/job-run/worker/tests/nomad_monitor_eval_update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use chirp_worker::prelude::*;

// #[worker_test]
// async fn basic(_ctx: TestCtx) {
// // TODO:
Expand Down
Loading

0 comments on commit 3d94f9c

Please sign in to comment.