Skip to content

Commit

Permalink
refactor: code related to cfs session logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Sopena Ballesteros committed Nov 10, 2023
1 parent f3ca43b commit f76cb00
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 75 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ 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.16.10"
mesa = { path = "../mesa" } # Only for development purposes
mesa = "0.16.11"
# mesa = { path = "../mesa" } # Only for development purposes
chrono = "0.4.31"
anyhow = "1.0.44"
reqwest = { version = "0.11", features = ["blocking", "json", "rustls-tls", "socks"] }
Expand Down
27 changes: 1 addition & 26 deletions src/cli/commands/apply_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,32 +212,7 @@ pub async fn exec(
.await
.unwrap();

// Get CFS session logs
let logs_stream_rslt = kubernetes::get_cfs_session_container_git_clone_logs_stream(
client.clone(),
&cfs_session.name,
)
.await;

match logs_stream_rslt {
Ok(mut logs_stream) => {
while let Some(line) = logs_stream.try_next().await.unwrap() {
println!("{}", line);
}
}
Err(error_msg) => log::error!("{}", error_msg),
}

let mut logs_stream = kubernetes::get_cfs_session_container_ansible_logs_stream(
client,
&cfs_session.name,
)
.await
.unwrap();

while let Some(line) = logs_stream.try_next().await.unwrap() {
println!("{}", line);
}
kubernetes::print_cfs_session_logs(client, &cfs_session.name).await;
}
}

Expand Down
48 changes: 1 addition & 47 deletions src/cli/commands/log.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use std::error::Error;

use futures::{io::Lines, AsyncBufReadExt, TryStreamExt};

use mesa::shasta::{cfs, hsm, kubernetes};

use crate::common::vault::http_client::fetch_shasta_k8s_secrets;
Expand All @@ -16,7 +12,6 @@ pub async fn exec(
k8s_api_url: &str,
cluster_name: Option<&String>,
session_name: Option<&String>,
// layer_id: Option<&u8>,
hsm_group_config: Option<&String>,
) {
// Get CFS sessions
Expand Down Expand Up @@ -57,46 +52,5 @@ pub async fn exec(
.await
.unwrap();

// Get CFS session logs
let logs_stream_rslt = kubernetes::get_cfs_session_container_git_clone_logs_stream(
client.clone(),
&cfs_session_name,
)
.await;

match logs_stream_rslt {
Ok(mut logs_stream) => {
while let Some(line) = logs_stream.try_next().await.unwrap() {
println!("{}", line);
}
}
Err(error_msg) => log::error!("{}", error_msg),
}

let mut logs_stream =
kubernetes::get_cfs_session_container_ansible_logs_stream(client, cfs_session_name)
.await
.unwrap();

while let Some(line) = logs_stream.try_next().await.unwrap() {
println!("{}", line);
}
kubernetes::print_cfs_session_logs(client, cfs_session_name).await;
}

/* pub async fn get_cfs_session_container_ansible_logs_stream(
vault_base_url: &str,
vault_secret_path: &str,
vault_role_id: &str,
cfs_session_name: &str,
k8s_api_url: &str,
) -> Result<Lines<impl AsyncBufReadExt>, Box<dyn Error + Sync + Send>> {
let shasta_k8s_secrets =
fetch_shasta_k8s_secrets(vault_base_url, vault_secret_path, vault_role_id).await;
let client = kubernetes::get_k8s_client_programmatically(k8s_api_url, shasta_k8s_secrets)
.await
.unwrap();
// Get CFS session logs
kubernetes::get_cfs_session_container_ansible_logs_stream(client, cfs_session_name).await
} */

0 comments on commit f76cb00

Please sign in to comment.