Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Matěj Laitl <[email protected]>
Co-authored-by: Jake McGinty <[email protected]>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent 29a1a15 commit bfc575b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,9 @@ fn rename_cidr(

let id = cidrs
.iter()
.filter(|c| c.name == old_name)
.map(|c| c.id)
.next()
.ok_or_else(|| anyhow!("CIDR not found."))?;
.find(|c| c.name == old_name)
.ok_or_else(|| anyhow!("CIDR not found."))?
.id;

api.http_form("PUT", &format!("/admin/cidrs/{id}"), cidr_request)?;
log::info!("CIDR renamed.");
Expand Down
1 change: 1 addition & 0 deletions server/src/db/cidr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl DatabaseCidr {
}

/// Update self with new contents, validating them and updating the backend in the process.
/// Currently this only supports updating the name and ignores changes to any other field.
pub fn update(&mut self, conn: &Connection, contents: CidrContents) -> Result<(), ServerError> {
let new_contents = CidrContents {
name: contents.name,
Expand Down
2 changes: 1 addition & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ fn rename_cidr(
.ok_or_else(|| anyhow!("CIDR not found."))?;
db::DatabaseCidr::from(db_cidr).update(&conn, cidr_request)?;
} else {
println!("exited without creating CIDR.");
println!("exited without renaming CIDR.");
}

Ok(())
Expand Down

0 comments on commit bfc575b

Please sign in to comment.