1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Perform a log lookup.

use std::process::Stdio;

use tokio::process::Command;

use super::{Reader, Result};

/// Initiate a log lookup (`kubectl log`) with the specified `kubectl_command`
/// for the specified `resource` at the specified `namespace`.
/// Returns a [`Reader`] that manages the reading process.
pub fn log_lookup(kubectl_command: &str, namespace: &str, resource: &str) -> Result<Reader> {
    let mut command = Command::new(kubectl_command);

    command.stdin(Stdio::null()).stderr(Stdio::inherit());

    command.arg("logs");
    command.arg("-f");
    command.arg("-n").arg(namespace);
    command.arg(resource);

    let reader = Reader::spawn(command)?;
    Ok(reader)
}