-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (33 loc) · 1.06 KB
/
main.go
File metadata and controls
37 lines (33 loc) · 1.06 KB
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
package main
import (
"flag"
"fmt"
"log"
)
var BuildVersion = "dev"
func main() {
conf := flag.String("config", "config.json", "path to config file or a http(s) url")
insecure := flag.Bool("insecure", false, "allow insecure HTTPS connections by skipping TLS certificate verification")
expandEnv := flag.Bool("expand-env", true, "expand environment variables in config file")
httpHeaders := flag.String("http-headers", "", "optional HTTP headers for config URL, format: 'Key1:Value1;Key2:Value2'")
httpTimeout := flag.Int("http-timeout", 10, "HTTP timeout in seconds when fetching config from URL")
version := flag.Bool("version", false, "print version and exit")
help := flag.Bool("help", false, "print help and exit")
flag.Parse()
if *help {
flag.Usage()
return
}
if *version {
fmt.Println(BuildVersion)
return
}
config, err := load(*conf, *insecure, *expandEnv, *httpHeaders, *httpTimeout)
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
err = startHTTPServer(config)
if err != nil {
log.Fatalf("Failed to start server: %v", err)
}
}