...
1 package podman
2
3 import (
4 "io"
5 "os/exec"
6
7 "k8s.io/klog"
8 )
9
10
11
12 func (o *PodmanCli) GetPodLogs(podName, containerName string, followLog bool) (io.ReadCloser, error) {
13 args := []string{"pod", "logs"}
14 if followLog {
15 args = append(args, "--follow")
16 }
17 if containerName != "" {
18 args = append(args, "--container", podName+"-"+containerName)
19 }
20 args = append(args, podName)
21
22 cmd := exec.Command(o.podmanCmd, append(o.containerRunGlobalExtraArgs, args...)...)
23 klog.V(3).Infof("executing %v", cmd.Args)
24
25 out, _ := cmd.StdoutPipe()
26
27 cmd.Stderr = cmd.Stdout
28 if err := cmd.Start(); err != nil {
29 return nil, err
30 }
31 return out, nil
32 }
33
View as plain text