Skip to content

Commit

Permalink
feat: show cfs configuration layer table in different rows
Browse files Browse the repository at this point in the history
feat: user new mesa library version
  • Loading branch information
Manuel Sopena Ballesteros committed Mar 15, 2024
1 parent 74487b0 commit 043591e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 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
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
mesa = "0.33.0"
mesa = "0.33.1"
# mesa = { path = "../mesa" } # Only for development purposes
strum = "0.25.0"
strum_macros = "0.25"
Expand Down
8 changes: 6 additions & 2 deletions src/cli/commands/get_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use mesa::{
self,
configuration::mesa::r#struct::{
cfs_configuration::{Configuration, Layer},
cfs_configuration_response::CfsConfigurationResponse,
cfs_configuration_response::{self, CfsConfigurationResponse},
},
},
common::gitea,
Expand Down Expand Up @@ -54,6 +54,9 @@ pub async fn exec(
let layer_details: Layer =
get_configuration_layer_details(shasta_root_cert, gitea_token, layer).await;

println!("DEBUG - layer :\n{:#?}", layer);
println!("DEBUG - layer details:\n{}", layer_details);

layers.push(layer_details);
}

Expand All @@ -71,7 +74,7 @@ pub async fn exec(
pub async fn get_configuration_layer_details(
shasta_root_cert: &[u8],
gitea_token: &str,
layer: &mesa::cfs::configuration::mesa::r#struct::cfs_configuration_response::Layer,
layer: &cfs_configuration_response::Layer,
) -> Layer {
let commit_id: String = layer.commit.clone().unwrap_or("Not defined".to_string());
// let branch_name_opt: Option<&str> = layer.branch.as_deref();
Expand Down Expand Up @@ -328,6 +331,7 @@ pub async fn get_configuration_layer_details(
.unwrap(),
&branch_name,
&tag_name,
&layer.playbook,
// most_recent_commit,
)
}
13 changes: 8 additions & 5 deletions src/common/cfs_configuration_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ pub fn print_table_struct(cfs_configurations: &Vec<CfsConfigurationResponse>) {
let layers_json = &cfs_configuration.layers;

layers = format!(
"COMMIT: {} NAME: {}",
"NAME: {}\nPLAYBOOK: {}\nCOMMIT: {}",
layers_json[0].name,
layers_json[0].playbook,
layers_json[0]
.commit
.as_ref()
.unwrap_or(&"Not defined".to_string()),
layers_json[0].name
);

for layer in layers_json.iter().skip(1) {
layers = format!(
"{}\nCOMMIT: {} NAME: {}",
"{}\n\nNAME: {}\nPLAYBOOK: {}\nCOMMIT: {}",
layers,
layer.name,
layer.playbook,
layer.commit.as_ref().unwrap_or(&"Not defined".to_string()),
layer.name
);
}
}
Expand All @@ -52,7 +54,7 @@ pub fn print_table_details_struct(cfs_configuration: Configuration) {

for layer in cfs_configuration.config_layers {
layers = format!(
"{}\n\nName: {}\nBranch: {}\nTag: {}\nCommit date: {}\nAuthor: {}\nSHA: {}",
"{}\n\nName: {}\nBranch: {}\nTag: {}\nCommit date: {}\nAuthor: {}\nSHA: {}\nPLAYBOOK: {}",
layers,
layer.name,
layer.branch,
Expand All @@ -65,6 +67,7 @@ pub fn print_table_details_struct(cfs_configuration: Configuration) {
layer.commit_date,
layer.author,
layer.commit_id,
layer.playbook
);
}

Expand Down

0 comments on commit 043591e

Please sign in to comment.