...
1 package helper
2
3 import (
4 "github.com/onsi/gomega/gexec"
5 )
6
7 type LogsSession struct {
8 session *gexec.Session
9 }
10
11
12
13 func StartLogsFollow(podman bool, opts ...string) (LogsSession, []byte, []byte, error) {
14 args := []string{"logs", "--follow"}
15 args = append(args, opts...)
16 if podman {
17 args = append(args, "--platform", "podman")
18 }
19 session := CmdRunner("odo", args...)
20
21 result := LogsSession{
22 session: session,
23 }
24 outContents := session.Out.Contents()
25 errContents := session.Err.Contents()
26 err := session.Out.Clear()
27 if err != nil {
28 return LogsSession{}, nil, nil, err
29 }
30 err = session.Err.Clear()
31 if err != nil {
32 return LogsSession{}, nil, nil, err
33 }
34 return result, outContents, errContents, nil
35 }
36
37
38 func (o *LogsSession) OutContents() []byte {
39 return o.session.Out.Contents()
40 }
41
42
43 func (o *LogsSession) Kill() {
44 o.session.Kill()
45 }
46
View as plain text