-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
60 lines (49 loc) · 1.35 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
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"github.com/robfig/cron/v3"
"k8s.io/client-go/util/homedir"
)
func main() {
var (
enableWebhook *bool
kubeconfig *string
schedule *string
)
// Kubeconfig flag
if home := homedir.HomeDir(); home != "" {
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
} else {
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
}
enableWebhook = flag.Bool("webhook", false, "Enable mutation webhook endpoint")
schedule = flag.String("schedule", "", "Cron schedule expression of the translations refreshes")
flag.Parse()
if *schedule != "" {
_, err := cron.ParseStandard(*schedule)
if err != nil {
fmt.Fprintf(os.Stderr, "-schedule flag cannot be parsed: %s", err)
}
}
config := &Config{
enableWebhook: *enableWebhook,
kubeconfig: *kubeconfig,
schedule: *schedule,
locoAPIKeys: map[string]string{
"catalog": os.Getenv("LOCO_API_KEY_CATALOG"),
"documents": os.Getenv("LOCO_API_KEY_DOCUMENTS"),
"emails": os.Getenv("LOCO_API_KEY_EMAILS"),
},
tlsCertFile: os.Getenv("TLS_CERT_FILE"),
tlsPrivateKeyFile: os.Getenv("TLS_PRIVATE_KEY_FILE"),
}
app := newApp(config)
err := app.Init()
if err != nil {
panic(err.Error())
}
app.Run()
}