...

Source file src/github.com/redhat-developer/odo/pkg/podman/exec.go

Documentation: github.com/redhat-developer/odo/pkg/podman

     1  package podman
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"io"
     7  	"os/exec"
     8  
     9  	"k8s.io/klog"
    10  )
    11  
    12  func (o *PodmanCli) ExecCMDInContainer(ctx context.Context, containerName, podName string, cmd []string, stdout, stderr io.Writer, stdin io.Reader, tty bool) error {
    13  	options := []string{}
    14  	if tty {
    15  		options = append(options, "--tty")
    16  	}
    17  
    18  	name := fmt.Sprintf("%s-%s", podName, containerName)
    19  
    20  	args := []string{"exec", "--interactive"}
    21  	args = append(args, options...)
    22  	args = append(args, name)
    23  	args = append(args, cmd...)
    24  
    25  	command := exec.CommandContext(ctx, o.podmanCmd, append(o.containerRunGlobalExtraArgs, args...)...)
    26  	command.Stdout = stdout
    27  	command.Stderr = stderr
    28  	command.Stdin = stdin
    29  	klog.V(3).Infof("executing %v", command.Args)
    30  	return command.Run()
    31  }
    32  

View as plain text