-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (39 loc) · 844 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
package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
)
func fatal(msg string, err error) {
panic(fmt.Sprintf("%s, %v", msg, err))
}
func waitForInterrupt() {
c := make(chan os.Signal, 5)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
}
func main() {
var config Config
if len(os.Args) == 2 {
var err error
config, err = ReadConfig(os.Args[1])
if err != nil {
fatal("couldn't read config", err)
}
}
if config.Namespace == "" {
config.Namespace = "default"
}
clientset, err := MakeK8Client()
if err != nil {
fatal("failed to create k8 client", err)
}
ctx, cancelFn := context.WithCancel(context.Background())
runner := MakeRunner(&config, clientset.CoreV1().Pods(config.Namespace))
runner.RunLogs(ctx)
waitForInterrupt()
cancelFn()
}