mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Change NewRunHandler params with Options * Pass an options to RunHandler to show logs * Hide spinner and std output since outputs are displayed * Integration tests with failing command * Fix outputs * use raw terminal and local standard i/o streams * Fix podman i/o * Fix stdout/err * Test if in/out are terminal * command reference doc
32 lines
752 B
Go
32 lines
752 B
Go
package podman
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"os/exec"
|
|
|
|
"k8s.io/klog"
|
|
)
|
|
|
|
func (o *PodmanCli) ExecCMDInContainer(ctx context.Context, containerName, podName string, cmd []string, stdout, stderr io.Writer, stdin io.Reader, tty bool) error {
|
|
options := []string{}
|
|
if tty {
|
|
options = append(options, "--tty")
|
|
}
|
|
|
|
name := fmt.Sprintf("%s-%s", podName, containerName)
|
|
|
|
args := []string{"exec", "--interactive"}
|
|
args = append(args, options...)
|
|
args = append(args, name)
|
|
args = append(args, cmd...)
|
|
|
|
command := exec.CommandContext(ctx, o.podmanCmd, append(o.containerRunGlobalExtraArgs, args...)...)
|
|
command.Stdout = stdout
|
|
command.Stderr = stderr
|
|
command.Stdin = stdin
|
|
klog.V(3).Infof("executing %v", command.Args)
|
|
return command.Run()
|
|
}
|