-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
54 lines (45 loc) · 1.21 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
package main
import (
"flag"
"github.com/mrahbar/k8s-nptest/integration"
"github.com/mrahbar/k8s-nptest/pkg"
"os"
)
var mode string
var debug bool
func init() {
flag.StringVar(&mode, "mode", "worker", "Mode for the daemon (worker | orchestrator)")
flag.BoolVar(&debug, "debug", false, "Increase debugging output")
}
func main() {
flag.Parse()
if !validateParams() {
integration.PrettyPrintErr("Failed to parse cmdline args - fatal error - bailing out")
os.Exit(1)
}
integration.PrintHeader("Running as "+mode+" ", '=')
if mode == pkg.OrchestratorMode {
pkg.Orchestrate(debug)
} else {
pkg.Work(debug)
}
integration.PrettyPrint("Terminating")
}
func validateParams() (rv bool) {
rv = true
if mode != pkg.WorkerMode && mode != pkg.OrchestratorMode {
integration.PrettyPrintErr("Invalid mode", mode)
return false
}
port := os.Getenv(pkg.EnvOrchestratorPort)
if mode == pkg.WorkerMode && len(port) == 0 {
integration.PrettyPrintErr("Invalid %s", pkg.EnvOrchestratorPort, port)
return false
}
address := os.Getenv(pkg.EnvOrchestratorPodIP)
if mode == pkg.WorkerMode && len(address) == 0 {
integration.PrettyPrintErr("Invalid %s", pkg.EnvOrchestratorPodIP, address)
return false
}
return
}