k8s_test_framework/
wait_for_rollout.rs

1//! Wait for a resource rollout to complete.
2
3use std::{ffi::OsStr, process::Stdio};
4
5use tokio::process::Command;
6
7use super::Result;
8use crate::util::run_command;
9
10/// Wait for a rollout of a `resource` within a `namespace` to complete via
11/// the specified `kubectl_command`.
12/// Use `extra` to pass additional arguments to `kubectl`.
13pub async fn run<Cmd, NS, R, Ex>(
14    kubectl_command: Cmd,
15    namespace: NS,
16    resource: R,
17    extra: impl IntoIterator<Item = Ex>,
18) -> Result<()>
19where
20    Cmd: AsRef<OsStr>,
21    NS: AsRef<OsStr>,
22    R: AsRef<OsStr>,
23    Ex: AsRef<OsStr>,
24{
25    let mut command = Command::new(kubectl_command);
26
27    command
28        .stdin(Stdio::null())
29        .stdout(Stdio::inherit())
30        .stderr(Stdio::inherit());
31
32    command.arg("rollout").arg("status");
33    command.arg("-n").arg(namespace);
34    command.arg(resource);
35    command.args(extra);
36
37    run_command(command).await?;
38    Ok(())
39}