-
Notifications
You must be signed in to change notification settings - Fork 62
/
main.go
38 lines (31 loc) · 875 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
//go:generate go run pkg/codegen/cleanup/main.go
//go:generate go run pkg/codegen/main.go
package main
import (
"context"
"os"
"github.com/rancher/webhook/pkg/server"
_ "github.com/rancher/wrangler/pkg/generated/controllers/admissionregistration.k8s.io"
"github.com/rancher/wrangler/pkg/kubeconfig"
"github.com/rancher/wrangler/pkg/ratelimit"
"github.com/rancher/wrangler/pkg/signals"
"github.com/sirupsen/logrus"
)
func main() {
if err := run(); err != nil {
logrus.Fatal(err)
}
}
func run() error {
cfg, err := kubeconfig.GetNonInteractiveClientConfig(os.Getenv("KUBECONFIG")).ClientConfig()
if err != nil {
return err
}
cfg.RateLimiter = ratelimit.None
ctx := signals.SetupSignalHandler(context.Background())
if err := server.ListenAndServe(ctx, cfg, os.Getenv("ENABLE_CAPI") == "true"); err != nil {
return err
}
<-ctx.Done()
return nil
}