Skip to content

Commit

Permalink
refactor: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Sopena Ballesteros committed Dec 11, 2023
1 parent 5053bd7 commit e1b48b4
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish = false # cargo dist --> Avoid publishing to crates.io
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
mesa = "0.18.1"
mesa = "0.18.2"
# mesa = { path = "../mesa" } # Only for development purposes
chrono = "0.4.31"
anyhow = "1.0.44"
Expand Down
1 change: 0 additions & 1 deletion src/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,4 +596,3 @@ pub fn subcommand_migrate_restore() -> Command {

migrate_restore
}

2 changes: 1 addition & 1 deletion src/cli/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pub mod log;
pub mod migrate_backup;
pub mod migrate_restore;
pub mod update_hsm_group;
pub mod update_node;
pub mod update_node;
3 changes: 2 additions & 1 deletion src/cli/commands/apply_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use mesa::{
capmc,
cfs::{
self,
session::{self, http_client::post, CfsSessionRequest}, configuration::r#struct::configuration::CfsConfigurationRequest,
configuration::r#struct::configuration::CfsConfigurationRequest,
session::{self, http_client::post, CfsSessionRequest},
},
hsm,
ims::image,
Expand Down
6 changes: 4 additions & 2 deletions src/cli/commands/apply_configuration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use mesa::shasta::cfs::{configuration::r#struct::configuration::CfsConfigurationRequest, self};
use mesa::shasta::cfs::{self, configuration::r#struct::configuration::CfsConfigurationRequest};
use serde_yaml::Value;
use std::path::PathBuf;

Expand Down Expand Up @@ -41,7 +41,9 @@ pub async fn exec(
}

if bos_session_template_list_yaml.is_some() {
log::warn!("SAT file has data in session_template section. This information will be ignored.")
log::warn!(
"SAT file has data in session_template section. This information will be ignored."
)
}

let empty_vec = &Vec::new();
Expand Down
10 changes: 9 additions & 1 deletion src/cli/commands/apply_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ use mesa::{
configuration::http_client::http_client::put,
session::{get_response_struct::CfsSessionGetResponse, http_client::http_client::post},
},
shasta::{kubernetes, cfs::{configuration::r#struct::{get_put_payload::CfsConfigurationResponse, configuration::CfsConfigurationRequest}, session::CfsSessionRequest}},
shasta::{
cfs::{
configuration::r#struct::{
configuration::CfsConfigurationRequest, get_put_payload::CfsConfigurationResponse,
},
session::CfsSessionRequest,
},
kubernetes,
},
};
use serde_yaml::Value;

Expand Down
3 changes: 2 additions & 1 deletion src/cli/commands/config_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ pub async fn exec(
let settings_hsm_available_vec = realm_access_role_vec; */

let hsm_group_available: Vec<String> =
get_hsm_name_available_from_jwt_or_all(shasta_token, shasta_base_url, shasta_root_cert).await;
get_hsm_name_available_from_jwt_or_all(shasta_token, shasta_base_url, shasta_root_cert)
.await;

let site_table: HashMap<String, Value> = settings.get_table("sites").unwrap();

Expand Down
13 changes: 7 additions & 6 deletions src/cli/commands/delete_data_related_to_cfs_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ use chrono::NaiveDateTime;
use comfy_table::Table;
use dialoguer::{theme::ColorfulTheme, Confirm};
use mesa::{
shasta, manta::{bos::template::get_image_id_from_bos_sessiontemplate_vec, cfs::session::get_image_id_from_cfs_session_vec},
manta::{
bos::template::get_image_id_from_bos_sessiontemplate_vec,
cfs::session::get_image_id_from_cfs_session_vec,
},
shasta,
};
use serde_json::Value;

Expand Down Expand Up @@ -185,14 +189,11 @@ pub async fn delete_data_related_cfs_configuration(
});

// Get image ids from CFS sessions and BOS sessiontemplate related to CFS configuration to delete
let image_id_from_cfs_session_vec =
get_image_id_from_cfs_session_vec(&cfs_session_value_vec);
let image_id_from_cfs_session_vec = get_image_id_from_cfs_session_vec(&cfs_session_value_vec);

// Get image ids from BOS session template related to CFS configuration to delete
let image_id_from_bos_sessiontemplate_vec =
get_image_id_from_bos_sessiontemplate_vec(
&bos_sessiontemplate_value_vec,
);
get_image_id_from_bos_sessiontemplate_vec(&bos_sessiontemplate_value_vec);

// Combine image ids from CFS session and BOS session template
let mut image_id_vec: Vec<&str> = [
Expand Down
11 changes: 9 additions & 2 deletions src/cli/commands/get_images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub async fn exec(
shasta_root_cert,
hsm_group_name_vec,
limit_number,
).await;
)
.await;

// Print data
let mut table = Table::new();
Expand All @@ -33,7 +34,13 @@ pub async fn exec(
]);

for image_details in image_detail_vec {
table.add_row(vec![image_details.0.id.as_ref().unwrap(), &image_details.0.name, image_details.0.created.as_ref().unwrap(), &image_details.1, &image_details.2]);
table.add_row(vec![
image_details.0.id.as_ref().unwrap(),
&image_details.0.name,
image_details.0.created.as_ref().unwrap(),
&image_details.1,
&image_details.2,
]);
}

println!("{table}");
Expand Down
5 changes: 4 additions & 1 deletion src/cli/commands/get_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ pub async fn exec(
bos_sessiontemplate_name_opt: Option<&String>,
limit_number_opt: Option<&u8>,
) {
log::info!("Get BOS sessiontemplates for HSM groups: {:?}", hsm_group_name_vec);
log::info!(
"Get BOS sessiontemplates for HSM groups: {:?}",
hsm_group_name_vec
);

let mut bos_sessiontemplate_vec = mesa::mesa::bos::sessiontemplate::http_client::get_all(
shasta_token,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/migrate_restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ pub async fn exec(
// } else {
// bos::template::utils::print_table(bos_templates);
// }
}
}
2 changes: 1 addition & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod bos_sessiontemplate_utils;
pub mod cfs_session_utils;
pub mod cfs_configuration_utils;
pub mod cfs_session_utils;
pub mod cluster_ops;
pub mod config_ops;
pub mod gitea;
Expand Down
4 changes: 2 additions & 2 deletions src/common/gitea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub mod http_client {
.trim_start_matches(gitea_internal_base_url)
.trim_end_matches(".git");
/* let repo_name = repo_name
.trim_start_matches(gitea_external_base_url)
.trim_end_matches(".git"); */
.trim_start_matches(gitea_external_base_url)
.trim_end_matches(".git"); */

log::info!("repo_url: {}", repo_url);
log::info!("gitea_base_url: {}", gitea_internal_base_url);
Expand Down
13 changes: 9 additions & 4 deletions src/common/node_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,15 @@ pub async fn validate_xnames(
xnames: &[&str],
hsm_group_name_opt: Option<&String>,
) -> bool {
let hsm_group_members: Vec<_> = if let Some(hsm_group_name) = hsm_group_name_opt {
hsm::http_client::get_hsm_group(shasta_token, shasta_base_url, shasta_root_cert, hsm_group_name)
.await
.unwrap()["members"]["ids"]
let hsm_group_members: Vec<_> = if let Some(hsm_group_name) = hsm_group_name_opt {
hsm::http_client::get_hsm_group(
shasta_token,
shasta_base_url,
shasta_root_cert,
hsm_group_name,
)
.await
.unwrap()["members"]["ids"]
.as_array()
.unwrap()
.to_vec()
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ async fn main() -> core::result::Result<(), Box<dyn std::error::Error>> {
.unwrap();

/* let site_available_vec = site_detail_hashmap
.keys()
.map(|site| site.clone())
.collect::<Vec<String>>(); */
.keys()
.map(|site| site.clone())
.collect::<Vec<String>>(); */

let shasta_base_url = site_detail_value
.get("shasta_base_url")
Expand Down

0 comments on commit e1b48b4

Please sign in to comment.