-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add methods to fetch tuple with image id, cfs configuration
and targets (either hsm group or nodes) from a list of jsons
- Loading branch information
Manuel Sopena Ballesteros
committed
Dec 7, 2023
1 parent
9d831c4
commit d731603
Showing
6 changed files
with
179 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod get_response_struct; | ||
pub mod http_client; | ||
pub mod post_request_struct; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use serde_json::Value; | ||
|
||
pub fn get_image_id_cfs_configuration_target_tuple_vec( | ||
cfs_session_value_vec: Vec<Value>, | ||
) -> Vec<(String, String, Vec<String>)> { | ||
let mut image_id_cfs_configuration_target_from_cfs_session: Vec<(String, String, Vec<String>)> = | ||
Vec::new(); | ||
|
||
cfs_session_value_vec | ||
.iter() | ||
.for_each(|cfs_session| { | ||
if let Some(result_id) = cfs_session.pointer("/status/artifacts/0/result_id") { | ||
let target: Vec<String> = | ||
if let Some(target_groups) = cfs_session.pointer("/target/groups") { | ||
target_groups | ||
.as_array() | ||
.unwrap() | ||
.iter() | ||
.map(|group| group["name"].as_str().unwrap().to_string()) | ||
.collect() | ||
} else if let Some(ansible_limit) = cfs_session.pointer("/ansible/limit") { | ||
ansible_limit | ||
.as_array() | ||
.unwrap() | ||
.iter() | ||
.map(|xname| xname.as_str().unwrap().to_string()) | ||
.collect() | ||
} else { | ||
vec![] | ||
}; | ||
|
||
image_id_cfs_configuration_target_from_cfs_session.push(( | ||
result_id.as_str().unwrap().to_string(), | ||
cfs_session | ||
.pointer("/configuration/name") | ||
.unwrap() | ||
.as_str() | ||
.unwrap() | ||
.to_string(), | ||
target, | ||
)); | ||
} else { | ||
image_id_cfs_configuration_target_from_cfs_session.push(("".to_string(), "".to_string(), vec![])); | ||
} | ||
}); | ||
|
||
image_id_cfs_configuration_target_from_cfs_session | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters