Skip to content

Commit

Permalink
rust: Run code formatting and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
YannikSc committed Jul 4, 2024
1 parent e024464 commit 961cec6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
16 changes: 14 additions & 2 deletions rust/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ impl Server {
));
}

if self.attributes.get(&attribute).as_array().unwrap().contains(&value) {
if self
.attributes
.get(&attribute)
.as_array()
.unwrap()
.contains(&value)
{
return Ok(self);
}

Expand Down Expand Up @@ -220,7 +226,13 @@ impl Server {
));
}

if !self.attributes.get(&attribute).as_array().unwrap().contains(&value) {
if !self
.attributes
.get(&attribute)
.as_array()
.unwrap()
.contains(&value)
{
return Ok(self);
}

Expand Down
8 changes: 4 additions & 4 deletions rust/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use signature::Signer;

use crate::API_VERSION;

pub const ENV_NAME_BASE_URL: &'static str = "SERVERADMIN_BASE_URL";
pub const ENV_NAME_TOKEN: &'static str = "SERVERADMIN_TOKEN";
pub const ENV_NAME_KEY_PATH: &'static str = "SERVERADMIN_KEY_PATH";
pub const ENV_NAME_SSH_AGENT: &'static str = "SSH_AUTH_SOCK";
pub const ENV_NAME_BASE_URL: &str = "SERVERADMIN_BASE_URL";
pub const ENV_NAME_TOKEN: &str = "SERVERADMIN_TOKEN";
pub const ENV_NAME_KEY_PATH: &str = "SERVERADMIN_KEY_PATH";
pub const ENV_NAME_SSH_AGENT: &str = "SSH_AUTH_SOCK";

#[derive(Clone, Debug, Default)]
pub struct Config {
Expand Down
8 changes: 6 additions & 2 deletions rust/src/new_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ impl NewObject {
})
}

pub async fn get_or_create(servertype: impl ToString, hostname: impl ToString) -> anyhow::Result<Self> {
pub async fn get_or_create(
servertype: impl ToString,
hostname: impl ToString,
) -> anyhow::Result<Self> {
let mut new_object = Self::request_new(servertype).await?;

if let Ok(server) = Query::builder()
Expand All @@ -32,7 +35,8 @@ impl NewObject {
.build()
.request()
.await?
.one() {
.one()
{
new_object.object_id = Some(server.object_id);
new_object.attributes = server.attributes;
}
Expand Down

0 comments on commit 961cec6

Please sign in to comment.