-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
53 lines (48 loc) · 890 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"os"
"os/exec"
"sync"
"flag"
)
var (
Version = "X.Y.Z" // injected at build time
v = flag.Bool("version", false, "Print version and exit")
)
func run(pod string, wg *sync.WaitGroup) {
defer wg.Done()
cmd := exec.Command("oc", "logs", "-f", "--timestamps=true", pod)
cmd.Stdout = os.Stdout
err := cmd.Start()
if err != nil {
fmt.Printf("%s", err)
return
}
err = cmd.Wait()
if err != nil {
fmt.Printf("%s exited with err %s", pod, err)
}
}
func stream(pods []string) *sync.WaitGroup {
var wg sync.WaitGroup
wg.Add(len(pods))
for _, pod := range pods {
go run(pod, &wg)
}
return &wg
}
func main() {
flag.Parse()
if *v {
fmt.Println(Version)
return
}
if len(os.Args) < 2 {
fmt.Println("Error: Invalid args. See readme.")
return
}
wg := stream(os.Args[1:])
wg.Wait()
fmt.Println("Streams completed. Main exiting.")
}