Skip to content

Commit

Permalink
fix bug when ims api returns only 1 image entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Sopena Ballesteros committed Oct 4, 2023
1 parent 207d979 commit ce35889
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/shasta/ims/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@ pub mod http_client {
return Err(resp.text().await?.into()); // Black magic conversion from Err(Box::new("my error msg")) which does not
};

let mut image_value_vec: Vec<Value> = json_response
.as_array_mut()
.unwrap_or(&mut Vec::new())
.to_vec();
log::info!("ims response:\n{:#?}", json_response);

let mut image_value_vec:Vec<Value> = if image_id_opt.is_some() {
[json_response].to_vec()
} else {
json_response
.as_array_mut()
.unwrap_or(&mut Vec::new())
.to_vec()
};

log::info!("image_value_vec:\n{:#?}", image_value_vec);

if let Some(hsm_group_name) = hsm_group_name_opt {
image_value_vec.retain(|image_value| {
Expand Down

0 comments on commit ce35889

Please sign in to comment.