-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
63 lines (53 loc) · 1.31 KB
/
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
54
55
56
57
58
59
60
61
62
63
package main
import (
"flag"
"fmt"
env "github.com/Netflix/go-env"
"k8s.io/klog"
"net/http"
"os"
)
var config = Config{
UseTLS: true,
CertFile: "/etc/swkac/tls.crt",
KeyFile: "/etc/swkac/tls.key",
TLSClientAuth: false,
TriggerENV: false,
SWImage: "lipangeng/skywalking-initcontainer:latest",
SWAgentCollectorBackendServices: "skywalking-aop.skywalking:11800",
SWJavaENVName: "JAVA_TOOL_OPTIONS",
}
func main() {
if _, err := env.UnmarshalFromEnviron(&config); err != nil {
klog.Error(err)
return
}
config.addFlags()
klog.InitFlags(nil)
flag.Parse()
showVersion()
http.HandleFunc("/health", health)
http.HandleFunc("/", serveMutatePods)
fmt.Println("Starting")
if config.UseTLS {
server := &http.Server{
Addr: ":443",
TLSConfig: configTLS(config),
}
_ = server.ListenAndServeTLS(config.CertFile, config.KeyFile)
} else {
server := &http.Server{
Addr: ":80",
}
_ = server.ListenAndServe()
}
}
func showVersion() {
if showVer {
fmt.Printf("build name:\t%s\n", BuildName)
fmt.Printf("build ver:\t%s\n", BuildVersion)
fmt.Printf("build time:\t%s\n", BuildTime)
fmt.Printf("Commit ID:\t%s\n", CommitID)
os.Exit(0)
}
}