Skip to content

Commit

Permalink
fix: converting from SAT to serde_yaml failing with wront field name for
Browse files Browse the repository at this point in the history
commit
refactor: clean std debug messages
  • Loading branch information
ManuelSopenaBallesteros committed Feb 15, 2024
1 parent 6e33a87 commit 4cecdfd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
10 changes: 8 additions & 2 deletions src/bos/template/shasta/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ pub async fn post(
shasta_root_cert: &[u8],
bos_template: &BosSessionTemplate,
) -> Result<Value, Box<dyn std::error::Error>> {
log::debug!("Bos template:\n{:#?}", bos_template);
log::debug!(
"BOS sessiontemplate creation request payload:\n{:#?}",
bos_template
);

let client;

Expand Down Expand Up @@ -74,7 +77,10 @@ pub async fn post(

if resp.status().is_success() {
let response = resp.json().await?;
log::debug!("Response:\n{:#?}", response);
log::debug!(
"BOS sessiontemplate creation response payload:\n{:#?}",
response
);
Ok(response)
} else {
let response: String = resp.text().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ impl CfsConfigurationRequest {

let repo_url = layer_yaml["git"]["url"].as_str().unwrap().to_string();

let commit_id_value_opt = layer_yaml["git"].get("commit_id");
let commit_id_value_opt = layer_yaml["git"].get("commit");
let tag_value_opt = layer_yaml["git"].get("tag");
let branch_value_opt = layer_yaml["git"].get("branch");

let commit_id: Option<String> = if commit_id_value_opt.is_some() {
// Git commit id
layer_yaml["git"]
.get("commit_id")
.get("commit")
.map(|commit_id| commit_id.as_str().unwrap().to_string())
} else if let Some(git_tag_value) = tag_value_opt {
// Git tag
Expand Down Expand Up @@ -162,7 +162,9 @@ impl CfsConfigurationRequest {
}

log::debug!(
"CRAY product catalog details (filtered):\n{:#?}",
"CRAY product catalog details for product: {}, version: {}:\n{:#?}",
product_name,
product_version,
product_details.unwrap()
);

Expand Down
12 changes: 8 additions & 4 deletions src/cfs/configuration/mesa/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ pub async fn create(
shasta_root_cert: &[u8],
cfs_configuration: &mut CfsConfigurationRequest,
) -> Result<CfsConfigurationResponse, ApiError> {
log::debug!("CFS configuration:\n{:#?}", cfs_configuration);
log::debug!(
"CFS configuration creation request payload:\n{:#?}",
cfs_configuration
);

let cfs_configuration_rslt = cfs::configuration::mesa::http_client::put(
shasta_token,
Expand All @@ -31,10 +34,11 @@ pub async fn create(

match cfs_configuration_rslt {
Ok(cfs_configuration) => {
println!(
"CFS configuration '{}' successfully created",
cfs_configuration.name
log::debug!(
"CFS configuration creation response payload:\n{:#?}",
cfs_configuration
);

Ok(cfs_configuration)
}
Err(error) => Err(ApiError::CsmError(error.to_string())),
Expand Down
18 changes: 12 additions & 6 deletions src/cfs/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ pub mod mesa {
shasta_root_cert: &[u8],
session: &CfsSessionPostRequest,
) -> Result<CfsSessionGetResponse, ApiError> {
log::debug!("CFS session creation request payload:\n{:#?}", session);

let response = crate::cfs::session::shasta::http_client::post(
shasta_token,
shasta_base_url,
Expand All @@ -673,7 +675,14 @@ pub mod mesa {
.unwrap();

if response.status().is_success() {
Ok(response.json::<CfsSessionGetResponse>().await.unwrap())
let response_payload = response.json::<CfsSessionGetResponse>().await.unwrap();

log::debug!(
"CFS session creation response payload:\n{:#?}",
response_payload
);

Ok(response_payload)
} else {
let error_detail = response.json::<serde_json::Value>().await.unwrap()["detail"]
.as_str()
Expand Down Expand Up @@ -898,8 +907,7 @@ pub mod mesa {
)> = Vec::new();

cfs_session_vec.iter().for_each(|cfs_session| {
if let Some(result_id) = cfs_session.get_result_id()
{
if let Some(result_id) = cfs_session.get_result_id() {
let target: Vec<String> = cfs_session
.get_target_hsm()
.or_else(|| cfs_session.get_target_xname())
Expand Down Expand Up @@ -937,9 +945,7 @@ pub mod mesa {
&& cfs_session.is_success()
&& cfs_session.get_result_id().is_some()
})
.map(|cfs_session| {
cfs_session.get_result_id().unwrap()
})
.map(|cfs_session| cfs_session.get_result_id().unwrap())
.collect::<Vec<String>>()
}
}
Expand Down

0 comments on commit 4cecdfd

Please sign in to comment.