k8s_test_framework/
log_lookup.rs

1//! Perform a log lookup.
2
3use std::process::Stdio;
4
5use tokio::process::Command;
6
7use super::{Reader, Result};
8
9/// Initiate a log lookup (`kubectl log`) with the specified `kubectl_command`
10/// for the specified `resource` at the specified `namespace`.
11/// Returns a [`Reader`] that manages the reading process.
12pub fn log_lookup(kubectl_command: &str, namespace: &str, resource: &str) -> Result<Reader> {
13    let mut command = Command::new(kubectl_command);
14
15    command.stdin(Stdio::null()).stderr(Stdio::inherit());
16
17    command.arg("logs");
18    command.arg("-f");
19    command.arg("-n").arg(namespace);
20    command.arg(resource);
21
22    let reader = Reader::spawn(command)?;
23    Ok(reader)
24}